-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Fix #21409: Make twin axes inherit parent position #31353
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
base: main
Are you sure you want to change the base?
Changes from all commits
d9ef7af
88d4ec5
a5435b5
ce749b4
5876d06
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4657,6 +4657,20 @@ def _make_twin_axes(self, *args, **kwargs): | |
| twin.set_zorder(self.zorder) | ||
|
|
||
| self._twinned_axes.join(self, twin) | ||
|
|
||
| # If the parent Axes has been manually positioned (set_position() sets | ||
| # in_layout=False), the SubplotSpec-based add_subplot(...) path ignores | ||
| # that manual position when creating a twin. In that case, explicitly | ||
| # copy both the original and active positions to the twin so they start | ||
| # aligned. | ||
| # | ||
| # For layout-managed Axes (in_layout=True), we keep the existing | ||
| # SubplotSpec-driven behavior, so layout engines such as tight_layout | ||
| # and constrained_layout continue to control positioning. | ||
| if not self.get_in_layout(): | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is all fine, but needs to be tested.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! I’ll add additional tests to cover this case.
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I added tests to cover both manual positioning and layout-managed cases. Let me know if anything else should be tested. |
||
| twin._set_position(self.get_position(original=True), which="original") | ||
| twin._set_position(self.get_position(original=False), which="active") | ||
|
|
||
| return twin | ||
|
|
||
| def twinx(self, axes_class=None, **kwargs): | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.