Thanks to visit codestin.com
Credit goes to github.com

Skip to content

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

Merged
merged 2 commits into from
Aug 8, 2024

Conversation

story645
Copy link
Member

@story645 story645 commented Aug 8, 2024

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

Because there are multiple axes here, titling the axes w. the function it's demoing helps highlight what's going on
@github-actions github-actions bot added the Documentation: examples files in galleries/examples label Aug 8, 2024
@QuLogic QuLogic added this to the v3.9-doc milestone Aug 8, 2024
@QuLogic QuLogic merged commit e1f88ba into matplotlib:main Aug 8, 2024
22 checks passed
Copy link

lumberbot-app bot commented Aug 8, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.9.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 e1f88ba6e36ba12c6376d9eb3878e7f62413022a
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #28677: Doc: add axes titles to axhspan/axvspan'
  1. Push to a named branch:
git push YOURFORK v3.9.x:auto-backport-of-pr-28677-on-v3.9.x
  1. Create a PR against branch v3.9.x, I would have named this PR:

"Backport PR #28677 on branch v3.9.x (Doc: add axes titles to axhspan/axvspan)"

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 Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

Copy link

lumberbot-app bot commented Aug 8, 2024

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.9.1-doc
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 e1f88ba6e36ba12c6376d9eb3878e7f62413022a
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #28677: Doc: add axes titles to axhspan/axvspan'
  1. Push to a named branch:
git push YOURFORK v3.9.1-doc:auto-backport-of-pr-28677-on-v3.9.1-doc
  1. Create a PR against branch v3.9.1-doc, I would have named this PR:

"Backport PR #28677 on branch v3.9.1-doc (Doc: add axes titles to axhspan/axvspan)"

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 Still Needs Manual Backport label once the PR gets merged.

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")
Copy link
Member

@timhoffm timhoffm Aug 8, 2024

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.

Copy link
Member Author

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.

Copy link
Member

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.

Copy link
Member Author

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:

Copy link
Member

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().

Copy link
Member Author

@story645 story645 Aug 8, 2024

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)

Copy link
Member

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.

Copy link
Member Author

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:

  1. 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)
  2. I'm fine if consensus is that examples get set _*, but then it needs to get documented

Copy link
Member Author

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?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Discussion moved to #28693

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants