Skip to content

DOC: fix levels in user/explain/figure #26110

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 1 commit into from
Jun 17, 2023

Conversation

jklymak
Copy link
Member

@jklymak jklymak commented Jun 12, 2023

PR summary

This fixes user/explain/figure, user/explain/axes, user/explain/artists to have a more conventional TOC page, followed by all the sub-pages. This is more like what sphinx expects, and makes the relevant sections show up as peers in the TOC.

Note there are no content changes other than the new TOC pages.

PR checklist

@jklymak jklymak force-pushed the doc-fix-levels-user-explain branch from 29865c6 to 038d067 Compare June 12, 2023 01:06
@jklymak
Copy link
Member Author

jklymak commented Jun 13, 2023

As an aside, learned that you can do

.. toctree::
    :maxdepth: 2

    axes_intro

.. toctree::
    :maxdepth: 1

    arranging_axes
    colorbar_placement

And the TOC in the sidebar will show all of the entries, but the page will render with a nested TOC with just the first entry expanded.

@jklymak
Copy link
Member Author

jklymak commented Jun 13, 2023

BTW, @story645 I'm all for having these TOCs be more visual, perhaps even with gallery-like cards. But I think these fixes should go in first just to get it organized better.

@rcomer
Copy link
Member

rcomer commented Jun 13, 2023

I like the the change to the TOCs, but I feel like something is now missing from the top level figure page. Maybe just a very basic description of what a figure is for between the title and the code block?

@jklymak
Copy link
Member Author

jklymak commented Jun 13, 2023

Ooops, yes, I meant to do that.

I also made the users_explain/index.rst into cards and maxdepth: 2 for better skim-ability. Some of the cards will need rebalancing later.

@story645
Copy link
Member

. But I think these fixes should go in first just to get it organized better.

Yeah that's fine - I agree in that like I think a good follow up will be reference pictures anchoring each section, but I respect keeping that discussion away from this one.

@tacaswell tacaswell added this to the v3.8.0 milestone Jun 15, 2023
Copy link
Member

@story645 story645 left a comment

Choose a reason for hiding this comment

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

Accidentally did a ton of content changes, (didn't see what was just moved from other file til I did the review 🤦‍♀️ ) let me know if I should push into their own PR. Basically, I'm concerned that we're doing the thing we do a lot in the docs of showing how to use something without really explaining what it is.

Otherwise, small organization suggestions that I do want addressed since I think the catch all pile at the end doesn't help w/ discoverability.

And my most nit nit is is there a way to remove the more reading link:
image

Comment on lines 57 to 62

axis/index
colors/index
text/index
animations/index
toolkits/index
Copy link
Member

Choose a reason for hiding this comment

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

Um can these be sorted out to the cards with related content?

axis/index -> axes
colors/index -> make this a card and show the second level
animations -> quickstart (this was always intended as a you don't need to know much tutorial)
text -> I would make this a card and show the second level 'cause again the annotation tutorial is buried
toolkits -> own card

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've reverted the changes to users_explain/index.rst so that can be in a separate PR


Usually we do not instantiate Artists directly, but rather use a plotting
method on `~.axes.Axes`. Some examples of plotting methods and the Artist
object they create is given below:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
object they create is given below:
object they create are given below:

Comment on lines +50 to +51
Note that ``plot`` returns a _list_ of lines because you can pass in multiple x,
y pairs to plot. The line has been added to the Axes, and we can retrieve the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Note that ``plot`` returns a _list_ of lines because you can pass in multiple x,
y pairs to plot. The line has been added to the Axes, and we can retrieve the
Note that ``plot`` returns a _list_ of lines because it generates multiple line plots when given multiple x,y pairs as input. The line has been added to the Axes, and we can retrieve the

little nit to tie return more closely to the visual generated

~~~~~~~~~~~~~~~~~~~~~~~~~~

Getting the ``lines`` object gives us access to all the properties of the
Line2D object. So if we want to change the *linewidth* after the fact, we can do so using `.Artist.set`.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Line2D object. So if we want to change the *linewidth* after the fact, we can do so using `.Artist.set`.
Line2D object. If we want to change the *linewidth* after the fact, we can do so using `.Artist.set`.

Comment on lines +76 to +77
We can interrogate the full list of settable properties with
`matplotlib.artist.getp`:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
We can interrogate the full list of settable properties with
`matplotlib.artist.getp`:
`matplotlib.artist.getp` returns the full list of settable properties:


The Axes class also has helpers to deal with Axis ticks and their labels. Most straight-forward is `~.axes.Axes.set_xticks` and `~.axes.Axes.set_yticks` which manually set the tick locations and optionally their labels. Minor ticks can be toggled with `~.axes.Axes.minorticks_on` or `~.axes.Axes.minorticks_off`.

Many aspects of Axes ticks and tick labeling can be adjusted using `~.axes.Axes.tick_params`. For instance, to label the top of the axes instead of the bottom,color the ticks red, and color the ticklabels green:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Many aspects of Axes ticks and tick labeling can be adjusted using `~.axes.Axes.tick_params`. For instance, to label the top of the axes instead of the bottom,color the ticks red, and color the ticklabels green:
Many aspects of Axes ticks and tick labeling can be adjusted using `~.axes.Axes.tick_params`. For instance, to label the top of the axes instead of the bottom, color the ticks red, and color the ticklabels green:

Comment on lines +19 to +20
When looking at Matplotlib visualization, you are almost always looking at
Artists placed on a `~.Figure`. In the example above, the figure is the
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
When looking at Matplotlib visualization, you are almost always looking at
Artists placed on a `~.Figure`. In the example above, the figure is the
The `~.Figure` object roughly corresponds to the total drawing area of an image. Usually, a Figure is the top level artist in the Matplotlib draw tree, which means it contains all the other artists that have been added to the image. The Figure and its contents are what gets rendered to a screen or file. `~.Subfigure` objects can be rendered independently or as part of the main `Figure`.
In the example above, the figure is the

Added some explanatory text, added the bit about subfigures b/c folks frequently ask to be able to render Axes.

Comment on lines +123 to +144
Users typically want an Axes or a grid of Axes when they create a Figure, so in
addition to `~.pyplot.figure`, there are convenience methods that return both
a Figure and some Axes. A simple grid of Axes can be achieved with
`.pyplot.subplots` (which
simply wraps `.Figure.subplots`):

.. plot::
:include-source:

fig, axs = plt.subplots(2, 2, figsize=(4, 3), layout='constrained')

More complex grids can be achieved with `.pyplot.subplot_mosaic` (which wraps
`.Figure.subplot_mosaic`):

.. plot::
:include-source:

fig, axs = plt.subplot_mosaic([['A', 'right'], ['B', 'right']],
figsize=(4, 3), layout='constrained')
for ax_name in axs:
axs[ax_name].text(0.5, 0.5, ax_name, ha='center', va='center')

Copy link
Member

Choose a reason for hiding this comment

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

I don't like that this is yet another mini-tutorial on subplots. This should just be something like
Typically data is plotted on an axes. To add one to a figure, see :ref: axes

Comment on lines +200 to +214
The `~.FigureBase` class has a number of methods to add artists to a `~.Figure` or
a `~.SubFigure`. By far the most common are to add Axes of various configurations
(`~.FigureBase.add_axes`, `~.FigureBase.add_subplot`, `~.FigureBase.subplots`,
`~.FigureBase.subplot_mosaic`) and subfigures (`~.FigureBase.subfigures`). Colorbars
are added to Axes or group of Axes at the Figure level (`~.FigureBase.colorbar`).
It is also possible to have a Figure-level legend (`~.FigureBase.legend`).
Other Artists include figure-wide labels (`~.FigureBase.suptitle`,
`~.FigureBase.supxlabel`, `~.FigureBase.supylabel`) and text (`~.FigureBase.text`).
Finally, low-level Artists can be added directly using `~.FigureBase.add_artist`
usually with care being taken to use the appropriate transform. Usually these
include ``Figure.transFigure`` which ranges from 0 to 1 in each direction, and
represents the fraction of the current Figure size, or ``Figure.dpi_scale_trans``
which will be in physical units of inches from the bottom left corner of the Figure
(see :ref:`transforms_tutorial` for more details).

Copy link
Member

Choose a reason for hiding this comment

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

Can this be broken up into bullets or distilled down to the most important bits? I'm concerned that this is a wall of text.

Saving Figures
==============

Finally, Figures can be saved to disk using the `~.Figure.savefig` method.
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
Finally, Figures can be saved to disk using the `~.Figure.savefig` method.
Figures can be saved to disk using the `~.Figure.savefig` method.

don't assume order of reading

@jklymak
Copy link
Member Author

jklymak commented Jun 15, 2023

Yeah, this only moved things, so if you want changes to the actual content, happy to look at PRs that do that.

The catchall is inelegant, but the whole top index needs work. The main point here is fixing the users/explain/*/index etc so that they are just indexes and the sub info are peers instead of the awkward. I did have a version where each item was its own card, but that is really worse as they're a bunch of very empty cards. I think we can follow up on that and that the proposed structure here is better than what we have. If you'd prefer I can revert the user/explain/index changes, and make a new PR to mess around with that.

@story645
Copy link
Member

I did have a version where each item was its own card, but that is really worse as they're a bunch of very empty cards.

I think I'm proposing a mix and match, which is kind of what I'm doing in #26086

@jklymak
Copy link
Member Author

jklymak commented Jun 16, 2023

I think I did mix and match. The subjects with substantive number of sub-headings have a separate card. Then there are the catch-alls.

@story645
Copy link
Member

Then there are the catch-alls

My problem with the catch alls is that they don't solve the major problem I'm having with both the user guide and the tutorial page, which is that the tutorials in the text and color section are no longer discoverable.

@jklymak
Copy link
Member Author

jklymak commented Jun 16, 2023

Sure agreed that definitely needs to be fixed. But that is orthogonal to this pr.

@jklymak
Copy link
Member Author

jklymak commented Jun 16, 2023

  • I've reverted the change to users/explain/index.
  • this PR largely only moved material, it didn't edit anything in the moved files. If there are changes desired to the moved material, those should be their own PR or issue, and not part of reviewing this PR.
  • the PR has new intro paragraphs for explain/figure/index, explain/axes/index, and explain/artist/index and a figure in each of those. These are copied almost verbatim from explain//_intro.rst.

Copy link
Member

@rcomer rcomer left a comment

Choose a reason for hiding this comment

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

I’ve not been through in detail, only clicked around the built docs. I think they look great! Since @story645 has been through the details and already approved, I think this is good to go.

@jklymak do you want to squash the commits? Either way feel free to self merge.

Co-authored-by: Ruth Comer <10599679+rcomer@users.noreply.github.com>
@jklymak jklymak force-pushed the doc-fix-levels-user-explain branch from 12c26ce to 9ec6407 Compare June 17, 2023 11:06
@jklymak jklymak merged commit f329eb8 into matplotlib:main Jun 17, 2023
@jklymak jklymak deleted the doc-fix-levels-user-explain branch June 17, 2023 15:41
@jklymak jklymak mentioned this pull request Jun 17, 2023
5 tasks
@story645 story645 mentioned this pull request Jul 13, 2023
5 tasks
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