Skip to content

DOC: Update Basic Usage tutorial #21800

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 4 commits into from
Dec 1, 2021
Merged

DOC: Update Basic Usage tutorial #21800

merged 4 commits into from
Dec 1, 2021

Conversation

StefRe
Copy link
Contributor

@StefRe StefRe commented Nov 29, 2021

PR Summary

1st commit: some minor fixes:

  • fix typos and PEP8 (line 338)
  • apply terminology and unify capitalization acc. to
    https://matplotlib.org/stable/devel/style_guide.html#terminology
  • insert missing # at line 133 to ensure correct sphinx formatting
  • replace -- by en dash (–), as smartquotes is set to False in conf.py
  • explicitly apply ConciseDateFormatter so that it's clear why the date
    axis is formatted the way it is (examples\ticks\date_concise_formatter.py
    registers the ConciseDateConverter and when the documentation is being
    built, this example is processed before the tutorials and hence the
    registered converter is still in effect)
  • apply auto aspect to imshow axes for a visually more pleasing effect
  • remove redundant redefinition of x at line 248

@jklymak I hope you don't mind my rather intrusive terminology edits, just trying to follow the style guide. I'm not happy with adding the ConciseDateConverter but without doing so the tutorial seems a bit misleading or confusing if someone is trying to reproduce this example and gets a different result. It would be better to undo the converter registration but I couldn't think of a good way to do so.

2nd commit: add additional axes section

Secondary and twin axes are rather important (although not necessarily
very basic) so they should be shortly mentioned with links to the API
docs where more detailed examples are linked (unfortunately there's no
tutorial on secondary and twin axes to refer to).

@jklymak Maybe you can rephrase these two short sections into clearer language (sorry for my limited command of English when it comes to writing documentation)

PR Checklist

Tests and Styling
[n/a] Has pytest style unit tests (and pytest passes).

  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation
[n/a] New features are documented, with examples if plot related.
[n/a] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
[n/a] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
[n/a] Documentation is sphinx and numpydoc compliant (the docs should build without error).

@jklymak
Copy link
Member

jklymak commented Nov 29, 2021

Lets maybe get #21794 in first...

@StefRe
Copy link
Contributor Author

StefRe commented Nov 29, 2021

@jklymak oops, sorry - didn't see it when I started this one. Yes of course, will rebase then if necessary.

@jklymak
Copy link
Member

jklymak commented Nov 29, 2021

many of these edits are great, and thanks for catching the spelling errors!

We need to be careful about mission creep in this document. You've suggested adding multiple axises/secondary axis to the figure. One could also add more colorbar, inset axes, etc etc. Maybe instead of full examples, lets just have some text that links to relevant examples for twinx and secondary_ax?

@StefRe
Copy link
Contributor Author

StefRe commented Nov 29, 2021

@jklymak

We need to be careful about mission creep in this document.

You're right, but IMHO a second y axis may be used more frequently than say math text or annotations (especially when you are used to Excel where you can send a data series with just one click to a second y axis on the right). I'd love to just refer to some tutorial on secondary, twin and shared and parasite axes (the latter two I left out intentionally), but there is none. So I tried to illustrate the concepts with two minimalistic examples as a short example is easier (at least for me) than describing the functionality in words.

Maybe we can combine the two paragraphs into one and show the examples side by side to make it even more concise (athough subplot are only introduced further down the tutorial, but the color mapped data section also uses subplots). But in the end I'm also happy with just the links to some examples.

@jklymak
Copy link
Member

jklymak commented Nov 29, 2021

Well, lets let others weigh in. My vote would be to trim rather than to add ;-)

There are quite a few twinx examples: https://matplotlib.org/stable/api/_as_gen/matplotlib.axes.Axes.twinx.html and there is a seocndary_axis example: https://matplotlib.org/stable/gallery/subplots_axes_and_figures/secondary_axis.html#sphx-glr-gallery-subplots-axes-and-figures-secondary-axis-py

@StefRe
Copy link
Contributor Author

StefRe commented Nov 29, 2021

@jklymak sure, no problem.

Just in case: this is a less space-consuming version by putting the plots side by side:

grafik

@tacaswell
Copy link
Member

I'm in favor of taking this extra section. I think twinned and secondary axes are on the same level of importance with annotations (but a bit behind math text) ;)

This is something that is particularly hard to describe to google so having a picture and link is 👍

@tacaswell tacaswell added this to the v3.6.0 milestone Nov 29, 2021
@story645
Copy link
Member

My vote would be to trim rather than to add ;-)

Is that a case for making an intermediate usage? Where basic is stripped down to how do I make one thing & label it, and intermediate is more of a grab bag of very commonly asked for things?

@jklymak
Copy link
Member

jklymak commented Nov 30, 2021

Please, no more grab bags!

But I'm warming to this section particular if it links out to the other examples. If the subject requires expansion or unification of those examples a new tutorial might make sense.

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Please rebase on #21794

Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Thanks for the thorough review and edit. Mostly looks good to me, but lets work on the new section. Consider next time two separate PRs - one for new material and the other for edits....

@jklymak jklymak added Documentation Documentation: website layout/behavior/styling changes and removed Documentation labels Nov 30, 2021
@jklymak jklymak modified the milestones: v3.6.0, v3.5-doc Nov 30, 2021
@StefRe StefRe force-pushed the fix/usage branch 2 times, most recently from af17fc6 to 2a62854 Compare November 30, 2021 10:56
@StefRe
Copy link
Contributor Author

StefRe commented Nov 30, 2021

@jklymak Sorry for being a pain in the neck, but I also changed constrained_layout=True to layout='constrained'. This tutorial states "This tutorial covers ... and best practices ...", so I thought it shouldn't show discouraged usage:

constrained_layout : bool, default: :rc:`figure.constrained_layout.use`
This is equal to ``layout='constrained'``.
.. admonition:: Discouraged
The use of this parameter is discouraged. Please use
``layout='constrained'`` instead.

@jklymak
Copy link
Member

jklymak commented Nov 30, 2021

No, not a pain - I forgot about that change.

- fix typos and PEP8 (line 338)
- apply terminology and unify capitalization acc. to
  https://matplotlib.org/stable/devel/style_guide.html#terminology
- replace -- by en dash (–), as smartquotes is set to False in conf.py
- explicitly apply ConciseDateFormatter so that it's clear why the date
  axis is formatted the way it is(examples\ticks\date_concise_formatter.py
  registers the ConciseDateConverter and when the documentation is being
  built, this example is processed before the tutorials and hence the
  registered converter is still in effect)
- remove redundant redefinition of x at line 246 and move definition of
  xdata at line 208 to where it is used
Secondary and twin axes are rather important (although not necessarily
very basic) so they should be shortly mentioned with links to the API
docs and some more detailed examples.
regarding implicit/explicit and pyplot/object oriented style
Copy link
Member

@jklymak jklymak left a comment

Choose a reason for hiding this comment

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

Thanks a lot @StefRe! looks good to me...

@jklymak jklymak merged commit 2e4189b into matplotlib:main Dec 1, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 1, 2021
meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Dec 1, 2021
@StefRe StefRe deleted the fix/usage branch December 1, 2021 15:22
timhoffm added a commit that referenced this pull request Dec 1, 2021
…800-on-v3.5.x

Backport PR #21800 on branch v3.5.x (DOC: Update Basic Usage tutorial)
timhoffm added a commit that referenced this pull request Dec 1, 2021
…800-on-v3.5.0-doc

Backport PR #21800 on branch v3.5.0-doc (DOC: Update Basic Usage tutorial)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Documentation: website layout/behavior/styling changes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants