-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
[Bug]: plt.subplots() cannot take the sharez or shareview keyword for 3D plots #25822
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
The issue is in There is no good solution here (but I can think of a bunch of bad ones!):
|
I tend to think your first option is the least bad - you can check and ignore those kwargs if your axes isn't 3d - but yeah would love to hear others' preferences! That option would also be an argument for bringing other keywords such as |
There is already a So I'm confused why those couldn't be added to that list within add_subplot instead of separately. |
subplot_kw won't work here as subplots(..., sharex=...) takes different inputs (True/False/"all"/"row"/"col") than add_subplot(..., sharex=...), so here it's not really a subplot for add_subplot() (*). So the sharex/y/z kwarg to subplots is really a different kwarg than the kwarg to add_subplot. (*) You could extend the semantics of add_subplot(..., sharex=...) to support True/False/"all"/"row"/"col" by saying that when one of these values is encountered, check whether there's a preceding axes on the figure that shares the same gridspec (and if necessary the same row/column), and if so, share with that axes and call label_outer() on that shared axes... This way everything is self-contained in the single-subplot constructor, but it does feel like API leakage. |
Bug summary
When initializing 3D plots using the plt.subplots interface, the
sharez
keyword is not implemented. This also applies to theshareview
keyword introduced in #25821.Would like to get some other opinions on if 3d-specific keywords should go into the Figure / subplots method.
Code for reproduction
Actual outcome
Expected outcome
Plot should generate and share z axes.
Matplotlib Version
latest main
Installation
None
The text was updated successfully, but these errors were encountered: