Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

keep the range of xaxis1 when toggling traces #7309

Open
Honghe opened this issue Dec 12, 2024 · 0 comments
Open

keep the range of xaxis1 when toggling traces #7309

Honghe opened this issue Dec 12, 2024 · 0 comments
Labels
feature something new P3 backlog

Comments

@Honghe
Copy link

Honghe commented Dec 12, 2024

Problem:

The fig has two xaxises, when toggled trace2, the range of xaxis1 was changed.

Feature request:

How to keep the range of xaxis1 like xaxis2 when toggle trace2?

Video.mp4

Code:

import plotly.graph_objects as go

fig = go.Figure()

x1 = [0, 1, 2, 3, 4, 5]
x2 = [100, 200, 300, 400, 500, 600]

fig.add_trace(
    go.Scatter(
        x=x1,
        y=[7] * 6,
        visible=False,
    )
)
fig.add_trace(
    go.Bar(
        x=[0, 1, 2],
        y=[1, 2, 3],
    )
)
fig.add_trace(
    go.Bar(
        x=[3, 4, 5],
        y=[4, 5, 6],
    )
)

# data3
fig.add_trace(
    go.Scatter(
        x=x2,
        y=[8] * 6,
    )
)

# create xaxis2
fig.update_layout(
    xaxis2={
        "anchor": "y",
        "side": "top",
        "overlaying": "x",
    },
)
# Re-assign scatter traces to axes created above
fig.data[3].update(xaxis="x2")

fig.show()
@gvwilson gvwilson changed the title feature request, keep the range of xaxis1 when toggle traces. keep the range of xaxis1 when toggling traces Dec 16, 2024
@gvwilson gvwilson added feature something new P3 backlog labels Dec 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature something new P3 backlog
Projects
None yet
Development

No branches or pull requests

2 participants