question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

make_subplots don't support multiple axis on the same track

See original GitHub issue

Mix the https://plot.ly/python/multiple-axes/ and https://plot.ly/python/subplots/.

In a subplot I don’t see how to setup several yaxis:

import plotly.graph_objs as go
from plotly import tools

from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
init_notebook_mode(connected=True)

trace1 = go.Scatter(
    x=[1, 2, 3],
    y=[40, 50, 60],
    name='yaxis data'
)
trace2 = go.Scatter(
    x=[2, 3, 4],
    y=[4, 5, 6],
    name='yaxis2 data',
    yaxis='y2'
)

data = [trace1, trace2]

layout = go.Layout(
    title='Double Y Axis Example',
    yaxis=dict(
        title='yaxis title'
    ),
    yaxis2=dict(
        title='yaxis2 title',
        titlefont=dict(
            color='rgb(148, 103, 189)'
        ),
        tickfont=dict(
            color='rgb(148, 103, 189)'
        ),
        overlaying='y',
        side='right'
    )
)

fig = tools.make_subplots(rows=1, cols=1)

fig.append_trace(trace1, 1, 1)
fig.append_trace(trace2, 1, 1)

# fig = go.Figure(data=data, layout=layout)
iplot(fig)

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:7 (4 by maintainers)

github_iconTop GitHub Comments

1reaction
cldouglcommented, Oct 29, 2016

Great thanks, here’s an example on how you can achieve that: https://plot.ly/~chelsea_lyn/13433 You can use multiple axes and define the domain and overlaying attributes

0reactions
VelizarVESSELINOVcommented, Oct 29, 2016

Thank very much, this help me a lot, a lot of code was needed to build the plot, but at the end it is working (the zoom it is slower than Bokeh, strange).

The order of domain [0 bottom, 1 top], anchors, overlaying, plus numbering system starting from 1 was strange to setup, I hope next time will be easier.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Multiple axes and subplots · ResGuides-Plotly - maegul
Initialise the figure​​ # two subplots, each in a row, forming one column fig = make_subplots(rows=2, cols=1, shared_xaxes=True) # sharing the x axis....
Read more >
Subplots in Python - Plotly
The shared_yaxes argument to make_subplots can be used to link the y axes of subplots in the resulting figure. Here is an example...
Read more >
Can't draw spike line across subplots with make_subplots in ...
After upgrading to plotly 4.0.0, I can't see how to create a spike line across shared axes created with make_subplots.
Read more >
python - plotly multiple axes that change dynamically with plot
I need to construct a plot with more than 2 y-axes, and I would like the axes to 'hide' and 'unhide' as the...
Read more >
Multiple Y-Axes with Plotly | #171 (Plotly Dash #5) - YouTube
I've made many charts using #matplotlib, but it became cumbersome trying to add interactivity. So, I've been creating more interactive ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found