-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
DOC: plotting section for Users Guide #29124
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
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,46 @@ | ||
| old_label,new_label | ||
| _contour_demo,_examples-contour-demo | ||
| _contourf_demo,_examples-contourf-demo | ||
| _contourf_log,_examples-contourf-log | ||
| _image_antialiasing,_examples-image-antialiasing | ||
| _image_resampling,_examples-image-resampling | ||
| _image_demo,_examples-image-demo | ||
| _pcolor_demo,_examples-pcolor-demo | ||
| _pcolormesh_grids,_examples-pcolormesh-grids | ||
| _plot_streamplot,_examples-plot-streamplot | ||
| _tricontour_demo,_examples-tricontour-demo | ||
| _tricontour_smooth_delaunay,_examples-tricontour-smooth-delaunay | ||
| _tricontour_smooth_user,_examples-tricontour-smooth-user | ||
| _tripcolor_demo,_examples-tripcolor-demo | ||
| _triplot_demo,_examples-triplot-demo | ||
| _categorical_variables,_examples-categorical-variables | ||
| _eventplot_demo,_examples-eventplot-demo | ||
| _fill_between_demo,_examples-fill-between-demo | ||
| _step_demo,_examples-step-demo | ||
| _bars3d,_examples-bars3d | ||
| _box3d,_examples-box3d | ||
| _custom_shaded_3d_surface,_examples-custom-shaded-3d-surface | ||
| _intersecting_planes,_examples-intersecting-planes | ||
| _quiver3d,_examples-quiver3d | ||
| _stem3d_demo,_examples-stem3d-demo | ||
| _surface3d,_examples-surface3d | ||
| _surface3d_2,_examples-surface3d-2 | ||
| _surface3d_3,_examples-surface3d-3 | ||
| _trisurf3d,_examples-trisurf3d | ||
| _trisurf3d_2,_examples-trisurf3d-2 | ||
| _boxplot_artists,_examples-boxplot-artists | ||
| _boxplot_color,_examples-boxplot-color | ||
| _boxplot_demo,_examples-boxplot-demo | ||
| _boxplot_vs_violin,_examples-boxplot-vs-violin | ||
| _customized_violin,_examples-customized-violin | ||
| _hexbin_demo,_examples-hexbin-demo | ||
| _histogram_histtypes,_examples-histogram-histtypes | ||
| _histogram_multihist,_examples-histogram-multihist | ||
| _histogram_normalization,_examples-histogram-normalization | ||
| _violinplot,_examples-violinplot | ||
| _bar3d_simple,_plot-types-bar3d-simple | ||
| _surface3d_simple,_plot-types-surface3d-simple | ||
| _trisurf3d_simple,_plot-types-trisurf3d-simple | ||
| _pcolormesh,_plot-types-pcolormesh | ||
| _users-guide-artists,_users-explain-users-guide-artists | ||
| _users_guide_axes,_users-explain-users-guide-axes |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -26,7 +26,7 @@ when the documentation is built. See :ref:`writing-docstrings`. | |
| Second, our example pages, tutorials, and some of the user guide are created by | ||
| `Sphinx Gallery`_. Sphinx Gallery converts Python files in :file:`galleries` to | ||
| ``*.rst`` files that contain the results of Matplotlib plot calls as embedded images. | ||
| See :ref:`writing-examples-and-tutorials`. | ||
| See :ref:`create-examples-and-tutorials`. | ||
|
|
||
| Third, Matplotlib has informative documentation written in ReST in subdirectories of | ||
| :file:`doc`. General and historical information about the project is in :file:`doc/project`, | ||
|
|
@@ -955,10 +955,10 @@ Example: | |
| .. inheritance-diagram:: matplotlib.patches matplotlib.lines matplotlib.text | ||
| :parts: 2 | ||
|
|
||
| .. _writing-examples-and-tutorials: | ||
| .. _create-examples-and-tutorials: | ||
|
|
||
| Write examples and tutorials | ||
| ============================ | ||
| Create examples and tutorials | ||
| ============================= | ||
|
|
||
| Examples and tutorials are Python scripts that are run by `Sphinx Gallery`_. | ||
| Sphinx Gallery finds ``*.py`` files in source directories and runs the files to | ||
|
|
@@ -967,25 +967,43 @@ location of the :file:`doc/` directory. Files in the build location should not | |
| be directly edited as they will be overwritten by Sphinx gallery. Currently | ||
| Matplotlib has four galleries as follows: | ||
|
|
||
| =============================== ========================== | ||
| Source location Build location | ||
| =============================== ========================== | ||
| :file:`galleries/plot_types` :file:`doc/plot_types` | ||
| :file:`galleries/examples` :file:`doc/gallery` | ||
| :file:`galleries/tutorials` :file:`doc/tutorials` | ||
| :file:`galleries/users_explain` :file:`doc/users/explain` | ||
| =============================== ========================== | ||
|
|
||
| The first three are traditional galleries. The last, | ||
| :file:`galleries/users_explain`, is a mixed gallery where some of the files are | ||
| raw ``*.rst`` files and some are ``*.py`` files; Sphinx Gallery just copies | ||
| these ``*.rst`` files from the source location to the build location (see | ||
| :ref:`raw_restructured_gallery`, below). | ||
| .. list-table:: | ||
| :widths: 20 28 22 30 | ||
| :header-rows: 1 | ||
|
|
||
| * - Gallery | ||
| - Source location | ||
| - Build location | ||
| - Purpose | ||
| * - ``users_explain`` | ||
| - :file:`galleries/users_explain` | ||
| - :file:`doc/users/explain` | ||
| - User guide narrative explanations of how to use Matplotlib. | ||
| * - ``plot_types`` | ||
| - :file:`galleries/plot_types` | ||
| - :file:`doc/plot_types` | ||
| - A curated overview of the plot types Matplotlib provides out of the box. | ||
| * - ``examples`` | ||
| - :file:`galleries/examples` | ||
| - :file:`doc/gallery` | ||
| - Visual examples that demonstrate features and usage patterns. | ||
| * - ``tutorials`` | ||
| - :file:`galleries/tutorials` | ||
| - :file:`doc/tutorials` | ||
| - Step-by-step guides for learning broader workflows in more depth. | ||
|
|
||
| See :ref:`organization-of-examples-and-tutorials` for more guidance about what | ||
| gallery to use for what purpose. | ||
|
|
||
| In terms of how they are created, the first three are traditional Sphinx | ||
| galleries. The last, :file:`galleries/users_explain`, is a mixed gallery where | ||
| some of the files are raw ``*.rst`` files and some are ``*.py`` files; Sphinx | ||
| Gallery just copies these ``*.rst`` files from the source location to the build | ||
| location (see :ref:`raw_restructured_gallery`, below). | ||
|
|
||
| In the Python files, to exclude an example from having a plot generated, insert | ||
| "sgskip" somewhere in the filename. | ||
|
|
||
|
|
||
| The format of these files is relatively straightforward. Properly | ||
| formatted comment blocks are treated as ReST_ text, the code is | ||
| displayed, and figures are put into the built page. Matplotlib uses the | ||
|
|
@@ -1142,8 +1160,56 @@ subdirectory, but :file:`galleries/users_explain/artists` has a mix of | |
| any ``*.rst`` files to a ``:toctree:``, either in the ``README.txt`` or in a | ||
| manual ``index.rst``. | ||
|
|
||
| Examples guidelines | ||
| ------------------- | ||
| .. _organization-of-examples-and-tutorials: | ||
|
|
||
| Organization of examples and tutorials | ||
| -------------------------------------- | ||
|
|
||
| Matplotlib's documentation has a summary of :ref:`plot_types`, a | ||
| :ref:`user_guide`, a large gallery of :ref:`examples-index`, and a small set of | ||
| :ref:`tutorials`. While this material overlaps in some ways, each section has | ||
| a different overall purpose and audience. The following guidelines are meant | ||
| to help authors decide where to place new material. | ||
|
|
||
| User's guide guidelines | ||
| ^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The user's guide is a collection of pages that explain how to use Matplotlib to | ||
| create visualizations. It should help readers understand the main concepts, | ||
| workflow, and decisions involved in making plots with Matplotlib. A reader | ||
| should have a solid understanding of how to approach common plotting tasks | ||
| after working through the user's guide, but it is not meant to be a | ||
| comprehensive API reference. | ||
|
|
||
| The user's guide should be organized as a coherent narrative so that pages can | ||
| be read linearly and build on previously introduced concepts. It should | ||
| contain more explanation and instruction than the gallery of examples, while | ||
| still being concise and to the point. Cross-link related documentation | ||
|
Comment on lines
+1185
to
+1187
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think that's the sticking point - the difference between user guide and example shouldn't just be that user guide is longer.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "...just be that the user guide is longer" is not what these sentences are meant to convey.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. That's what "more than" conveys.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Again, I think the full three paragraphs conveys a lot more than that. If that is all you got out of it, edit suggestions, or comments about what you didn't understand are welcome to make the point clearer.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What I'm not understanding is if structurally/modally there's supposed to be anything different about a user guide page vs. a tutorial or user guide page vs. an example. Like "Customizing Plots" could be a tutorial or a user guide entry or a gallery example. We have it in all three flavors - current rc guide, lifestyle of a plot has a lot of styling guidance, examples w/ a styling:type tag. So what distinguishes it as a user guide entry if it's not just "more explanation"? minimal/focused code is the same guidance as for examples.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Overlap is expected. But instead of asking “Where does page X belong?”, we should ask, “What does the User Guide need in order to be reasonably comprehensive?” |
||
| (e.g. tutorials, gallery examples, and API entries) and tag the page with | ||
| related concepts. | ||
|
|
||
| The user's guide should be organized into sections that cover related topics. | ||
| For example, a section on "Customizing Plots" might include pages on how to | ||
| change colors, fonts, and line styles. Each page should have a clear title that | ||
| describes the content of the page. The code examples should be minimal and | ||
| focused on the concept being explained. Avoid including extraneous code that | ||
| does not directly contribute to the explanation. | ||
|
Comment on lines
+1194
to
+1196
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Honestly, to me some of the examples in this PR don't follow these guidelines. Which I agree w/ in theory, which makes me wonder if we have different definitions of "concept being explained" and "extraneous". What I'm thinking of in particular is what I see in the comments as digressions on implementation details (aspect, aliasing, color cycles). And also (as I think Tim also mentioned) most of the focus in the preamble of these functions is on the data - I'm feeling like the plotting concept is getting completely lost here.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Matplotlib is a scientific data visualization tool. Usually scientists have data they want to plot, so I think discussing the data types (pairwise, gridded, etc) and various way to represent that data is a relatively useful way to contextualize. It is also exactly how Plot Types is organized. I'm not sure what "plotting concept(s)" are bing lost. As for digressions, there may indeed be some. It will be a question whether we should add more, or reduce them, but I expect the former. The ones included were ones I felt were important.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
I think if they're important enough to be mentioned, then they should get a proper subsection/paragraph heading w/ explaination on why you're telling them this. Otherwise it feels like a distraction from whatever they're supposed to be learning in the specific example. Mostly cause someone reading the plotting section of the user guide is likely missing all the context for why this is important to know.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
B/c plot types is answering the "what chart types can I choose from?" question, while I think user guide is supposed to answer "what can I do w/ the chart type I chose?
For example, the start of the gridded data section is a paragraph and a half on gridded data. There isn't even a brief introduction to the plotting methods, something like "the regular gridded data plotting methods all plot variants of a heatmap, which is a visualization where the data values Some of this is addressed on the specific methods, but like we both know that it's the
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, first sentence fixed, but note this section is not just about colormapping as contours need not be colored. As for mapping using norms, a full explanation is linked, and maybe more could be explained here. However, I consider that somewhat intermediate, and I bet 95% of our users never create a norm directly.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
That's why I (and I think Tim) were pushing for some/sub organization under viz type. Group heatmap like functions together so all the shared concepts (colormaps, norms) can be discussed under that header and then the function how tos can be streamlined to the function specific differences. Main reason plot types gallery doesn't have that sub organization is b/c we don't go into that level of detail there. Bonus is easier to edit when we add explainations about colorizer later.
I've probably been using Matplotlib almost 20 years and I don't think I've ever really cared about the aspect but you think it's very important for understanding how to use imshow. Which fine, I think norm is one of those things that's really important to understand even if you don't make one directly b/c it underpins all the colormapping (at least currently). |
||
|
|
||
| The material should stay relatively balanced and move between basic and more | ||
| advanced concepts in as natural a manner as possible. The goal is for a user to | ||
| read the material without having to spend too much effort trying to understand | ||
| the examples. Deep dives into one feature set should usually live elsewhere and | ||
| be linked as further reading when appropriate. | ||
|
Comment on lines
+1201
to
+1202
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. where? example gallery? |
||
|
|
||
| .. note:: | ||
|
|
||
| The user's guide contains some older material that was ported over from | ||
| Tutorials, so some of the content may not yet conform to the suggestions | ||
| above. | ||
|
|
||
|
|
||
| Examples gallery guidelines | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The gallery of examples contains visual demonstrations of matplotlib features. Gallery | ||
| examples exist so that users can scan through visual examples. Unlike tutorials or user | ||
|
|
@@ -1157,7 +1223,7 @@ documentation (e.g. tutorials, user guides and API entries) and tag the example | |
| related concepts. | ||
|
|
||
| Format | ||
| ^^^^^^ | ||
| ~~~~~~ | ||
|
|
||
| All :ref:`examples-index` should aim to follow these guidelines: | ||
|
|
||
|
|
@@ -1198,15 +1264,36 @@ makes it easier for the reader to map which parts of code correspond to which pa | |
| the plot. | ||
|
|
||
| Figure size | ||
| ^^^^^^^^^^^ | ||
| ~~~~~~~~~~~ | ||
| When customizing figure sizes, we aim to avoid downscaling in rendered HTML docs. | ||
| The current width limit (induced by *pydata-sphinx-theme*) is 720px, i.e. | ||
| ``figsize=(7.2, ...)``, or 896px if the page does not have subsections and | ||
| thus does not have the "On this page" navigation on the right-hand side. | ||
|
|
||
| Tutorials guidelines | ||
| ^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| Plot types guidelines | ||
| --------------------- | ||
| Tutorials are step-by-step guides for learning broader workflows in more depth. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. can you define broader workflows b/c I'm struggling w/ how artist tutorial is a broader workflow. Granted, I also think it should be folded into the user guide entry on artists.
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These are general guidelines, not meant to cover everything that already exists or be overly binding. |
||
| They should contain explanation and instruction, and can be more cross-cutting | ||
| than individual sections of the user's guide and more in-depth than an | ||
| example. Tutorials need not be limited to assuming basic Matplotlib knowledge, | ||
|
Comment on lines
+1277
to
+1279
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. what's the criteria for more cross-cutting and more in depth? |
||
| but should clearly state the assumed level of knowledge and learning goals in | ||
| the introduction. | ||
|
|
||
| Long-form tutorials should be organized as a coherent narrative, with sections | ||
| that build on one another and contribute to a clear end result. Break the | ||
| material into stages with clear subsections, and make it easy for readers to see | ||
| what each section adds and when to refer to other documentation for deeper | ||
| detail on a specific feature. A table of contents may be helpful for longer | ||
| tutorials. | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion but the thumbnail?header image should usually be the finished product as that'll give folks the "why do I want to read this?"
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The purpose here is not to tell people how to write these. Thumbnails are covered above.
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The rest of this paragraph is content suggestions: sections/headings/toc. This is just another content suggestion. |
||
|
|
||
| Formatting guidelines are the same as for Examples above. Cross-link | ||
| related documentation (e.g. user guides, gallery examples, and API entries) and | ||
| tag the page with related concepts. | ||
|
|
||
|
|
||
| Plot types gallery guidelines | ||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
|
||
| The :ref:`plot_types` gallery provides an overview of the types of visualizations that | ||
| Matplotlib provides out of the box, meaning that there is a high-level API for | ||
|
|
@@ -1215,7 +1302,8 @@ because this gallery is heavily curated and tightly scoped to methods on | |
| `matplotlib.axes.Axes`. | ||
|
|
||
| Format | ||
| ^^^^^^ | ||
| ~~~~~~ | ||
|
|
||
| :title: Method signature with required arguments, e.g. ``plot(x, y)`` | ||
| :description: In one sentence, describe the visualization that the method produces and | ||
| link to the API documentation, e.g. *Draws a bar chart. See ~Axes.bar*. | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,5 @@ | ||
| """ | ||
| .. _contourf_demo: | ||
| ============= | ||
| Contourf demo | ||
| ============= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _contourf_log: | ||
| ============================ | ||
| Contourf and log color scale | ||
| ============================ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,8 @@ | ||
| """ | ||
| .. _image_antialiasing: | ||
| .. _image_resampling: | ||
| ================ | ||
| Image resampling | ||
| ================ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _image_demo: | ||
|
|
||
| ======================== | ||
| Many ways to plot images | ||
| ======================== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _pcolor_demo: | ||
| ============= | ||
| pcolor images | ||
| ============= | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _plot_streamplot: | ||
| ========== | ||
| Streamplot | ||
| ========== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _tricontour_demo: | ||
| =============== | ||
| Tricontour Demo | ||
| =============== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _tricontour_smooth_user: | ||
| ====================== | ||
| Tricontour Smooth User | ||
| ====================== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _tripcolor_demo: | ||
|
|
||
| ============== | ||
| Tripcolor Demo | ||
| ============== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _triplot_demo: | ||
|
|
||
| ============ | ||
| Triplot Demo | ||
| ============ | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _eventplot_demo: | ||
| ============== | ||
| Eventplot demo | ||
| ============== | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,4 +1,6 @@ | ||
| """ | ||
| .. _step_demo: | ||
| ========= | ||
| Step Demo | ||
| ========= | ||
|
|
||
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.
can these be one column/ two lines?
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 didn't take this suggestion..
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.
It just takes up a lot of white space/is particularly bad on mobile:
