-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Doc: add axes titles to axhspan/axvspan #28677
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
Conversation
Because there are multiple axes here, titling the axes w. the function it's demoing helps highlight what's going on
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
And apply the correct labels and milestones. Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon! Remember to remove the If these instructions are inaccurate, feel free to suggest an improvement. |
@@ -29,6 +29,7 @@ | |||
ax2.axvspan(mu+sigma, mu+2*sigma, color='0.95') | |||
ax2.axvline(mu, color='darkgrey', linestyle='--') | |||
ax2.plot(x, y) | |||
ax2.set(title="axvspan") |
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.
Side note, maybe not enough to change in hindsight, but to set future practice:
I would generally favor set_thing(x)
over set(thing=x)
for single properties.
And in this particular example, I would also have kept the two properties ax1.set(ylim=(-1.5, 1.5), title="axhspan")
above separate. Mainly because of symmetry with ax2.set_title
and to a lesser degree because ylim and title are quite different properties.
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 the opposite in that I prefer .set for properties that aren't the focus of the example and we don't need any of the other kwargs, mostly b/c so many folks complain "why must I write all this boilerplate" and this is less boilerplate.
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.
Axes.set()
is similar to pyplot
. It's a convenience interface that people can use to simplify their code - if they know what they are doing, but it does not provide the full capability. I'd say: If you only want to learn or teach the minimal stuff, stick with set_*()
. Only when it's a real simplification, use set()
. - Possibly this is something we should discuss and agree on a strategy, like wie did with Axes-interface vs. pyplot. It's not helpful if the docs do it one way or the other depending on the author.
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.
Looked up if we did in the meeting notes and agreeing that first step is probably writing a user guide entry:
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 for digging that up 🚀. I'm sure I advocated for "advertise set()
more". But I don't agree with
one-shot set aimed at use cases who are using us as an application and the set_XYZ for when we are being used internal to a third-party library.
That's not the criterion for me. Instead, I would like to advertise set()
as a shortcut. As API lead I see the need and call for a discussion on how we consider and in which cases we want to advertise set()
.
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 fine w/ a new discussion and then us documenting the decision at https://matplotlib.org/devdocs/devel/style_guide.html#terminology, please add it to the agenda for a week you'll be on the call or maybe open an issue? (we really need a consistent way to do not call based/asynch discussions)
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.
The set_title method is far more featureful and should usually be preferred to set(title=) unless there is some reason to be concise. Using nonstandard patterns trips up reading an example and I don't think there is a strong argument to use "set" as a standard.
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.
My reasons for conciseness were:
- Setting the title isn't an important part of this PR, it's done here mostly to quickly line up figure w/ method b/c there are two being demoed
- The set method is a good way to quickly handle a bunch of boilerplate where you don't need the kwargs, b/c frequent complaint is too much boilerplate
That being said:
- As discussed in the meeting, this may be better handled by a new user guide entry/rework of the artists guide (and a section of the quick start guide for set on axis)
- I'm fine if consensus is that examples get set _*, but then it needs to get documented
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.
set_title method is far more featureful
Yes, but none of those features are needed for this example and if someone needs those features they can look at one of our set_title examples?
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.
Discussion moved to #28693
Because there are multiple axes here, titling the axes w. the function it's demoing helps highlight what's going on. Basically, would have found titles helpful for the discussion in #28152 (comment)
PR checklist