Open
Conversation
- Bug was that function marked the axis to be connected, but the trace_kwargs still had unique axes - Change: change the keyword argument for the trace, so that when the graph is initialized, it uses the correct axis instead of the autogenerated one - Note: The program generates a unique axis label for each subgraph, and then overwrites the label (under this fix)
Author
|
I just wanted to say that the label used to sync all of the axes together is last generated one, ie instead of using "x", it will use "x2" as the label for both of axes. This is because it is the last graph (the bottom one) that has the labeling on the axis. Looking at the code that was already there, this seems to be the intended outcome, but it doesn't seem intuitive to me. If it isn't intended, it may need to change more (including how the graph is initialized and the order which things are processed), but I didn't want to make too big of a change. Let me know if this is right or wrong. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Link to issue
Closes #5427
Description of change
Demo
Testing strategy
Used this test code to see if the line showed up; since this is a visibility test, no unit tests were provided
`# Create sample data
df = pd.DataFrame({
'x': pd.date_range('2024-01-01', periods=100),
'y1': range(100),
'y2': [x**2 for x in range(100)]
})
Create subplots
fig = make_subplots(
rows=2, cols=1,
shared_xaxes=True,
vertical_spacing=0.02
)
fig.add_trace(go.Scatter(x=df['x'], y=df['y1'], name='Line 1'), row=1, col=1)
fig.add_trace(go.Scatter(x=df['x'], y=df['y2'], name='Line 2'), row=2, col=1)
fig.update_traces(xaxis='x2')
fig.update_xaxes(
showspikes=True,
spikemode='across',
spikesnap='cursor',
spikecolor='black',
spikethickness=1
)
fig.update_layout(hovermode='x unified')
fig.show()`
Additional information (optional)
This is my first pull request, so please let me know if there is anything
Guidelines