-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Feature Idea: Make subplots return an AxisList object instead of a numpy array #9434
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
Comments
That is a pretty good idea, however I have some back-compatibility concerns as the returned object would have to also be a I think the best course of action is to prototype it (maybe dropping the full numpy compatibility). Instead of it being the default return type of fig, ax_grid = plt.subplots()
nice_grid = NiceGrid(ax_grid)
nice_grid[:, 1].set_ylabel() If the prototype goes well we can then sort out if this would be better as a small package on pypi or someplace as a helper in Matplotlib core. |
Thank you for your response! Not making that a default sounds reasonable. I will try to prototype as a small independent package and update here as soon as I've made progress. |
Plus one on this idea! I’m not even sure how big a deal it is for backwards compatibility so long as it supports most of the indexing and reshaping ndarray commands. |
I think this can also help with avoiding the |
Could you explain that further?
…On Oct 16, 2017 5:45 PM, "Antony Lee" ***@***.***> wrote:
I think this can also help with avoiding the squeeze=False dance.
—
You are receiving this because you authored the thread.
Reply to this email directly, view it on GitHub
<#9434 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/AKRwuzWziCt4dmWyyKh1fgcPTrdnJq00ks5ss3oVgaJpZM4P6b0n>
.
|
Right now if you write Now, if the AxesList object (however we name it) returned also has whatever methods an Axes has, then you're fine even if you don't pass On the other hand, having thought about it again, I think another reasonable (unrelated) option would have been (probably too late to change it...) to have the signature |
But I really like the basic idea here. There is no need for axes to be ndarrays, other than the fact we like them to be iterable as a 2-D array. Being able to do |
On the other hand, note that the desired functionality is already available as (e.g.) |
Wow I did not know that you could pass multiple objects to plt.setp. |
I would consider this at least an argument against it. |
Btw. Is there a good place in the docs were setting properties of multiple axis at once could be shown? I don't think many people are aware of that. |
It's implicitly (but not very clearly) documented at http://matplotlib.org/gallery/misc/set_and_get.html#sphx-glr-gallery-misc-set-and-get-py (when setp is called on But yes the docs could use some improvement. |
I just realised that we would also need to support nested attributes, like |
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! |
Superseded by #25937, which in a first step decouples the code from the array implementation while keeping API compatibility. This is reasonable anyway to narrow he API surface. Preventing Tab-completion to list a lot of nonsensical and often not working operation is by itself an improvement. Expanding or modifying behavior will be a second step. |
Hey,
This is a short idea I had when creating complex graphs with multiple subplots.
Sometimes you want to apply the same actions to multiple subplots and a way that feels very natural would be something like this:
This does of course not work, but could be easily be achieved by returning a custom object that wraps a list of axes instances and overwrites the
__getitem__
method.Of course it would need to reimplement all axes methods, but it might be possible to do that by just forwarding all call in a modified
__getattribute__
or by automatically creating wrapped classmethods in a metaclass.With such a custom object it might even be possible to support something like this:
If there is interest in such functionality, I would try to build a working prototype.
Other than that, thanks to everybody for all the awesome work you put into matplotlib!
Regards,
Arne
The text was updated successfully, but these errors were encountered: