Skip to content

Allow shared_yaxes to work with secondary axes #5180

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

gmjw
Copy link

@gmjw gmjw commented May 12, 2025

The shared_yaxes parameter to make_subplots did not previously work on secondary y-axes. It had no effect.

This PR fixes this, without affecting how the parameter is applied to normal plots (without secondary y-axes). I have added a simple test to show how the new code "matches" secondary y-axes. The sharing for secondary y-axes is applied right-to-left, in the same way that the sharing for primary y-axes is applied left-to-right (I believe this results in the clearest separation of tick marks when viewing the final plot).

I believe this is a bugfix/improvement. I'm not sure if it's a new feature worthy of any documentation.

I will add some images showing a before/after comparison in comments.

@gmjw
Copy link
Author

gmjw commented May 12, 2025

This is the output of the test adjusted in the PR, with shared_yaxes=True, before and after the changes. You can see that after the changes the secondary y-axes are shared across rows, whereas previously only primary y-axes were shared.

fig_test_before
fig_test_after

@gmjw
Copy link
Author

gmjw commented May 12, 2025

This is my first PR to this repo, I've done my best but please let me know if there's anything I've forgotten or that could be done better.

In particular I'm not sure if/how I should add to the CHANGELOG file.

[{"secondary_y": True}, {"secondary_y": True}],
],
)
for shared_y_axes in [False, True]:
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ideally I would have passed in these options using mark.parametrize, but I don't think that is possible with unittest TestCase methods.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant