keep the range of xaxis1 when toggling traces
Open
Nobody has claimed this yet.
feature
P3
- Dominant language
- JavaScript
- Stars
- 18.3k
- Forks
- 2k
- Avg merge
- 2d 12h
- Merged PRs (30d)
- 28
Description
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?
https://github.com/user-attachments/assets/cf3ac904-8ae4-4cfa-9783-193196c327df
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()
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by running the supplied Plotly example and toggling the traces while observing the overlaid xaxis1 and xaxis2 ranges. Investigate the range update behavior during trace toggling; done means xaxis1 keeps its current range while xaxis2 continues to behave as shown.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- data-visualization
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100