Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Allowshared_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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
emilykl merged 10 commits intoplotly:mainfromgmjw:secondary-y-shared
Oct 1, 2025

Conversation

@gmjw
Copy link
Contributor

@gmjwgmjw commentedMay 12, 2025
edited
Loading

  • I have read through thecontributing notes and understand the structure of the package. In particular, if my PR modifies code of plotly.graph_objects, my modifications concern the codegen files and not generated files.
  • I have added tests (if submitting a new feature or correcting a bug) or modified existing tests.
  • For a new feature, I have added documentation examples in an existing or new tutorial notebook (please see the doc checklist as well).
  • I have added a CHANGELOG entry if fixing/changing/adding anything substantial.
  • For a new feature or a change in behaviour, I have updated the relevant docstrings in the code to describe the feature or behaviour (please see the doc checklist as well).

Theshared_yaxes parameter to make_subplots did not previously work onsecondary 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
ContributorAuthor

gmjw commentedMay 12, 2025
edited
Loading

This is the output of the test adjusted in the PR, withshared_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
ContributorAuthor

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}],
],
)
forshared_y_axesin [False,True]:
Copy link
ContributorAuthor

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 usingmark.parametrize, but I don't think that is possible with unittest TestCase methods.

@gvwilsongvwilson self-assigned thisMay 20, 2025
@gvwilsongvwilson added featuresomething new P2considered for next cycle communitycommunity contribution labelsMay 20, 2025
@gvwilson
Copy link
Contributor

thanks@gmjw - I'll try to get this merged in for the 6.2 release.

@gmjw
Copy link
ContributorAuthor

Thanks@gvwilson - just checking in to see if this could be merged soon - thanks!

@gvwilsongvwilson requested review fromemilykl andgvwilson and removed request formarthacryanJune 26, 2025 12:39
Comment on lines 751 to 754
ifsecondary_y:
_configure_shared_axes(
layout,grid_ref,specs,"y",shared_yaxes,row_dir,True
)
Copy link
Contributor

Choose a reason for hiding this comment

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

@gmjw I think there's a logic issue here --secondary_y is set in the loop above, which loops through all thespecs for each subplot. So after the above loop terminates,secondary_y corresponds only to the value provided forsecondary_y in the spec of the final subplot.

You can see how this causes issues if you set'secondary_y': False for the final subplot only; it breaks shared y-axes for every subplot in the grid.

The fix might be as simple as something like this:

Suggested change
ifsecondary_y:
_configure_shared_axes(
layout,grid_ref,specs,"y",shared_yaxes,row_dir,True
)
any_secondary_y=any([spec.get("secondary_y",False)forspec_rowinspecsforspecinspec_row])
ifany_secondary_y:
_configure_shared_axes(
layout,grid_ref,specs,"y",shared_yaxes,row_dir,True
)

although I haven't fully thought through all the edge cases.

Copy link
ContributorAuthor

@gmjwgmjwJul 19, 2025
edited
Loading

Choose a reason for hiding this comment

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

Hi@emilykl - thanks for spotting this! I should have read through the function more carefully.

I've adjusted almost as you suggest - based on the loop above, it looks like I can rely on "secondary_y" being inspec providedspec is not None.

@gmjw
Copy link
ContributorAuthor

Hi@gvwilson - just to say that I hope this is ready to merge now, if you have time to review. Thanks!

@gvwilsongvwilson requested review fromcamdecoster and removed request forgvwilsonAugust 1, 2025 11:59
@gvwilsongvwilson added P1needed for current cycle and removed P2considered for next cycle labelsAug 1, 2025
@gvwilson
Copy link
Contributor

cc@emilykl one more review and merge?

@gmjw
Copy link
ContributorAuthor

Hi@emilykl - no rush but just wanted to bump this PR for another look if you have time, many thanks!

Copy link
Contributor

@emilyklemilykl left a comment

Choose a reason for hiding this comment

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

Yes, this can be merged — sorry for the delay@gmjw and thank you for your patience!

@emilyklemilykl merged commitb258862 intoplotly:mainOct 1, 2025
8 checks passed
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@emilyklemilyklemilykl approved these changes

@camdecostercamdecosterAwaiting requested review from camdecoster

Assignees

@gvwilsongvwilson

Labels

communitycommunity contributionfeaturesomething newP1needed for current cycle

Projects

None yet

Milestone

No milestone

Development

Successfully merging this pull request may close these issues.

3 participants

@gmjw@gvwilson@emilykl

[8]ページ先頭

©2009-2025 Movatter.jp