Skip to content

shared twinned subplots: support ax.twinx(sharey=...) / ax.twiny(sharex=...) #8392

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

Closed
anntzer opened this issue Mar 28, 2017 · 3 comments
Closed
Labels
status: inactive Marked by the “Stale” Github Action

Comments

@anntzer
Copy link
Contributor

anntzer commented Mar 28, 2017

After

fig, (ax1, ax2) = plt.subplots(2, sharex=True, sharey=True)
ax1.plot([1, 2]); ax2.plot([1, 2])
ax1.twinx().plot([2, 1]); ax2.twinx().plot([2, 1])

zooming/panning one of the subplots only affects the other subplot along the x axis, but not the y axis -- because zooming/panning affects the twinned subplots, which only share their x axis, whereas the y sharing is lost (of course, it cannot always be shared with the original subplots -- the sharing needs to occur directly between the twinned subplots).

Having thought approximately 30s about the issue, I believe an easy way out would be to support passing an explicit share{y,x} argument to twin{x,y} (for the "other" axis, as the twinned axis is already shared with the original subplot, of course), so that one can properly re-link the twinned subplots between themselves.

@kundor
Copy link

kundor commented Apr 4, 2017

An easy way to implement this is to add **kwargs to the signature of twinx and twiny

def twinx(self, **kwargs):

and pass them along to _make_twin_axes in the first line of code:

ax2 = self._make_twin_axes(sharex=self, **kwargs)

This allows passing on arbitrary keyword arguments for the newly constructed axes, including sharex or sharey.

@github-actions
Copy link

This issue has been marked "inactive" because it has been 365 days since the last comment. If this issue is still present in recent Matplotlib releases, or the feature request is still wanted, please leave a comment and this label will be removed. If there are no updates in another 30 days, this issue will be automatically closed, but you are free to re-open or create a new issue if needed. We value issue reports, and this procedure is meant to help us resurface and prioritize issues that have not been addressed yet, not make them disappear. Thanks for your help!

@github-actions github-actions bot added the status: inactive Marked by the “Stale” Github Action label Apr 10, 2023
@anntzer
Copy link
Contributor Author

anntzer commented Apr 11, 2023

This is more or less covered by #15287 (post-hoc sharing).

@anntzer anntzer closed this as completed Apr 11, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: inactive Marked by the “Stale” Github Action
Projects
None yet
Development

No branches or pull requests

2 participants