Ask Your Question

How can I eliminate the stacked Plotly graphs?

asked 2023-02-08 11:00:00 +0000

pufferfish gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2022-09-20 16:00:00 +0000

nofretete gravatar image

To eliminate stacked Plotly graphs, you can use the "overlay" option in the layout. Here's an example:

import plotly.graph_objs as go

fig = go.Figure()

trace1 = go.Scatter(
    x=[1, 2, 3],
    y=[4, 5, 6],

trace2 = go.Scatter(
    x=[1, 2, 3],
    y=[7, 8, 9],


    title='Overlayed Plot',
    yaxis2=dict(title='Y2-Axis', overlaying='y', side='right')

In this code, the yaxis2 is added to the layout with the overlaying='y' parameter. This allows the two traces to be overlaid on top of each other, rather than stacked. Additionally, the side='right' parameter moves the second y-axis to the right side of the plot.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer

Question Tools


Asked: 2023-02-08 11:00:00 +0000

Seen: 13 times

Last updated: Sep 20 '22