Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork8.1k
Prefer add_subplot(foo=bar) to subplots(subplot_kw={"foo": bar}).#14411
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
jkseppan left a comment
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.
Makes sense to me
timhoffm commentedJun 2, 2019
+0.5. I think, this is more readable for the cases presented here. I'm a bit worried on the So if we're going away from "just use |
efiring commentedJun 3, 2019
The advantage of |
timhoffm commentedJun 3, 2019
I agree that the explicit figure creation has its merit, and partly withdraw my argument that This whole axes creation is a bit of a mess. If we did not have history would look like a reaonable API to me (maybe with optional pyplot shortcuts using implicit figure creation). But we're not there. The latter is I'm really worried we're confusing users with all these different methods and changed recommendations for axes creation. Even if Essentially, I see two reasonable ways:
This is just an of-the-top of my head concept and certainly would need more thorough consideration. |
anntzer commentedJun 3, 2019 • edited
Loading Uh oh!
There was an error while loading.Please reload this page.
edited
Uh oh!
There was an error while loading.Please reload this page.
Well, I would really have preferred to have I agree that ever-changing recommendations are not great :( but OTOH we're all (well, at least I'm definitely still) learning how to best design an API. I guess this discussion is also colliding with#14421 now. |
jklymak commentedJul 5, 2019
I'm not a fan of favouring a different API for a single subplot than for multiple subplots, and I'm not at all a fan of |
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
anntzer commentedJun 19, 2023
Since this Pull Request has not been updated in 60 days, it has been marked "inactive." This does not mean that it will be closed, though it may be moved to a "Draft" state. This helps maintainers prioritize their reviewing efforts. You can pick the PR back up anytime - please ping us if you need a review or guidance to move the PR forward! If you do not plan on continuing the work, please let us know so that we can either find someone to take the PR over, or close it. |
timhoffm left a comment
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.
I'm still very undecided betweensubplots(..., subplot_kw=...) andfigure().add_subplot().
Personally, I likely wouldn't actively rewrite this, but also wouldn't block if you push this forward again.
We should definitively limit the kwargs to polar and 3d. Everything else (see suggestions) should not be crammed into the subplots creation. This is a change that can be made independently of above decision.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
When creating a single subplot I think the former is more readable.(Note that before mpl3.1 one had to write `add_subplot(111, foo=bar)`where the tradeoff was less clear.)
anntzer commentedAug 23, 2023
OK, I rewrote the whole thing to just make the changes that should be uncontroversial. |
story645 commentedAug 23, 2023
Uh I hate to jump in this late but I'm concerned about the
My concern is w/ the folks who won't realize it's a chained call...I know the () should be a giveaway but I don't think it will be. I'd rather go all the way explicit here and use the unchained construction and leave "you can chain" to a section of the user guide or a tutorial. |
anntzer commentedAug 23, 2023
I think acrucial point of python semantics as opposed to matlab (which is still pretty commonly used in my field) is exactly that youcan chain calls, i.e. |
story645 commentedAug 23, 2023
I don't disagree in the case where they're definitely not going to use the figure object, but my concern is that this is example gallery code where the expectation is folks will c&p and then tweak. I think I agree w/@jklymak that we should probably pin down a standard. |
anntzer commentedAug 24, 2023
Let's just close this until we can actually decide on a standard. |
esibinga commentedAug 24, 2023
re: deciding on a standard: Is there an existingstandard for constructing a figure / axes / subplots? I see this in Getting Started: Given that figure/ax construction is both super confusing for beginners and ubiquitous for using mpl, I think that specifically warrants a standard that the gallery examples really stick to. That way users can focus on the feature they're looking for, without having to detangle how the figure is constructed. If a different setup is unavoidable or nonsensical for 3D projections etc, it may be worth anticipating confusion by adding a link at the bottom of the example page to thequick start guide or another tutorial that explains the difference in setup. That seems to me to be potentially aseparate question from a standard about using chained calls in general. I'm ambivalent there -- it seems easier to figure out when it's later on in the code, but I would avoid shortcuts in the setup. And FWIW, personally I think |
jklymak commentedAug 24, 2023
We have already added width_ratio and height_ratio as pass throughs. The only one I really miss is facecolor I think in general passing the figure back to the user is quite often necessary even in the case of a single subplot - in particular for colorbars. We could have ax.colorbar but again, having a separate idiom for single axes versus multiple axes in the docs seems confusing. I think we should always use fig, axs = plt.subplots() for consistency, even if there is just one axes. |
While technical possible, this is an anti-pattern IMHO.We should keep Axes creation and customization separate.Extracted frommatplotlib#14411.
While technical possible, this is an anti-pattern IMHO.We should keep Axes creation and customization separate.Extracted frommatplotlib#14411.
When creating a single subplot I think the former is more readable.
(Note that before mpl3.1 one had to write
add_subplot(111, foo=bar)where the tradeoff was less clear.)
Happy to discuss which form to prefer...
PR Summary
PR Checklist