-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Propagate Axes class and kwargs for twinx and twiny #29325
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
Propagate Axes class and kwargs for twinx and twiny #29325
Conversation
687849d
to
b1d6a54
Compare
I'm somewhat hesitant to do this. While it looks feasible at first glance, I've some reservations:
|
Hi @timhoffm , thank you for the comments. Twinning is powerful for time serieses with different units
When plotting time series data, it happens that several serieses with different units are to be shown in a single figure, with which users would like to interact. One can use the time labels as the shared x axis to twin two overlapping subplots, each has its own y axis with its own unit. This enables simultaneous interaction on the subplots; paning and zooming in one subplot act in the same way on the shared axes of both subplots. Subclassing
|
@cmp0xff could you give an example of a use-case where you need both a subclass and a twinned axes? I appreciate the value of subclasses and I have added functionality to Matplotlib to handle them (#22608). For that PR I had a specific subclass in mind (the Cartopy GeoAxes) as shown in the PR summary. Do you have a specific subclass in mind for this? |
b1d6a54
to
2feddad
Compare
Hi @rcomer , thank you for your hints. After some research, I have realised that what I described above has mostly been implemented by parasite_axes in the In practise, we have an in-house extension of Now that in |
Thanks, this sounds like a reasonable application. I'm fundamentally ok with extending/modifying the behavior of Design considerations:
|
2feddad
to
a9c8ca4
Compare
a9c8ca4
to
b337f94
Compare
b337f94
to
a228f5d
Compare
Hi @timhoffm ,
After some thinking, I would go for keeping the current behaviour, defaulting to The reason is that some subclasses use |
de198d2
to
ecb384e
Compare
- https://github.com/matplotlib/matplotlib/pull/29325/files#r1894693106 - https://github.com/matplotlib/matplotlib/pull/29325/files#r1894693188 - https://github.com/matplotlib/matplotlib/pull/29325/files#r1894696478 Co-authored-by: Tim Hoffmann <2836374+timhoffm@users.noreply.github.com>
3b117c0
to
18589f3
Compare
Hi, it has been two weeks since the last update. May I ask for a second approval / a critical review? Thanks and happy new year. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @cmp0xff, I just have some comments on the docstrings.
…lib#29325 (comment) Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
df825b1
to
883f049
Compare
- matplotlib#29325 (comment) - matplotlib#29325 (comment) - matplotlib#29325 (comment) Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
883f049
to
bb8e374
Compare
PR summary
Why is this change necessary?
Users may wish to inherit
matplotlib.axes.Axes
, see e.g. https://stackoverflow.com/q/48593124.twinx
/twiny
in the subclass should return subclass instances, instead ofAxes
.kwargs
,twinx
/twiny
should also be able to accept these extra arguments.What problem does it solve?
The proposed changes fix the behaviour of the methods mentioned above..
What is the reasoning for this implementation?
We try to keep the changes to a minimum and maintain current behaviours.
PR checklist