@@ -26,7 +26,7 @@ when the documentation is built. See :ref:`writing-docstrings`.
2626Second, our example pages, tutorials, and some of the user guide are created by
2727`Sphinx Gallery `_. Sphinx Gallery converts Python files in :file: `galleries ` to
2828``*.rst `` files that contain the results of Matplotlib plot calls as embedded images.
29- See :ref: `writing -examples-and-tutorials `.
29+ See :ref: `create -examples-and-tutorials `.
3030
3131Third, Matplotlib has informative documentation written in ReST in subdirectories of
3232:file: `doc `. General and historical information about the project is in :file: `doc/project `,
@@ -955,10 +955,10 @@ Example:
955955 .. inheritance-diagram :: matplotlib.patches matplotlib.lines matplotlib.text
956956 :parts: 2
957957
958- .. _ writing -examples-and-tutorials :
958+ .. _ create -examples-and-tutorials :
959959
960- Write examples and tutorials
961- ============================
960+ Create examples and tutorials
961+ =============================
962962
963963Examples and tutorials are Python scripts that are run by `Sphinx Gallery `_.
964964Sphinx 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
967967be directly edited as they will be overwritten by Sphinx gallery. Currently
968968Matplotlib has four galleries as follows:
969969
970- =============================== ==========================
971- Source location Build location
972- =============================== ==========================
973- :file: `galleries/plot_types ` :file: `doc/plot_types `
974- :file: `galleries/examples ` :file: `doc/gallery `
975- :file: `galleries/tutorials ` :file: `doc/tutorials `
976- :file: `galleries/users_explain ` :file: `doc/users/explain `
977- =============================== ==========================
978-
979- The first three are traditional galleries. The last,
980- :file: `galleries/users_explain `, is a mixed gallery where some of the files are
981- raw ``*.rst `` files and some are ``*.py `` files; Sphinx Gallery just copies
982- these ``*.rst `` files from the source location to the build location (see
983- :ref: `raw_restructured_gallery `, below).
970+ .. list-table ::
971+ :widths: 20 28 22 30
972+ :header-rows: 1
973+
974+ * - Gallery
975+ - Source location
976+ - Build location
977+ - Purpose
978+ * - ``users_explain ``
979+ - :file: `galleries/users_explain `
980+ - :file: `doc/users/explain `
981+ - User guide narrative explanations of how to use Matplotlib.
982+ * - ``plot_types ``
983+ - :file: `galleries/plot_types `
984+ - :file: `doc/plot_types `
985+ - A curated overview of the plot types Matplotlib provides out of the box.
986+ * - ``examples ``
987+ - :file: `galleries/examples `
988+ - :file: `doc/gallery `
989+ - Visual examples that demonstrate features and usage patterns.
990+ * - ``tutorials ``
991+ - :file: `galleries/tutorials `
992+ - :file: `doc/tutorials `
993+ - Step-by-step guides for learning broader workflows in more depth.
994+
995+ See :ref: `organization-of-examples-and-tutorials ` for more guidance about what
996+ gallery to use for what purpose.
997+
998+ In terms of how they are created, the first three are traditional Sphinx
999+ galleries. The last, :file: `galleries/users_explain `, is a mixed gallery where
1000+ some of the files are raw ``*.rst `` files and some are ``*.py `` files; Sphinx
1001+ Gallery just copies these ``*.rst `` files from the source location to the build
1002+ location (see :ref: `raw_restructured_gallery `, below).
9841003
9851004In the Python files, to exclude an example from having a plot generated, insert
9861005"sgskip" somewhere in the filename.
9871006
988-
9891007The format of these files is relatively straightforward. Properly
9901008formatted comment blocks are treated as ReST _ text, the code is
9911009displayed, 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
11421160any ``*.rst `` files to a ``:toctree: ``, either in the ``README.txt `` or in a
11431161manual ``index.rst ``.
11441162
1145- Examples guidelines
1146- -------------------
1163+ .. _organization-of-examples-and-tutorials :
1164+
1165+ Organization of examples and tutorials
1166+ --------------------------------------
1167+
1168+ Matplotlib's documentation has a summary of :ref: `plot_types `, a
1169+ :ref: `user_guide `, a large gallery of :ref: `examples-index `, and a small set of
1170+ :ref: `tutorials `. While this material overlaps in some ways, each section has
1171+ a different overall purpose and audience. The following guidelines are meant
1172+ to help authors decide where to place new material.
1173+
1174+ User's guide guidelines
1175+ ^^^^^^^^^^^^^^^^^^^^^^^
1176+
1177+ The user's guide is a collection of pages that explain how to use Matplotlib to
1178+ create visualizations. It should help readers understand the main concepts,
1179+ workflow, and decisions involved in making plots with Matplotlib. A reader
1180+ should have a solid understanding of how to approach common plotting tasks
1181+ after working through the user's guide, but it is not meant to be a
1182+ comprehensive API reference.
1183+
1184+ The user's guide should be organized as a coherent narrative so that pages can
1185+ be read linearly and build on previously introduced concepts. It should
1186+ contain more explanation and instruction than the gallery of examples, while
1187+ still being concise and to the point. Cross-link related documentation
1188+ (e.g. tutorials, gallery examples, and API entries) and tag the page with
1189+ related concepts.
1190+
1191+ The user's guide should be organized into sections that cover related topics.
1192+ For example, a section on "Customizing Plots" might include pages on how to
1193+ change colors, fonts, and line styles. Each page should have a clear title that
1194+ describes the content of the page. The code examples should be minimal and
1195+ focused on the concept being explained. Avoid including extraneous code that
1196+ does not directly contribute to the explanation.
1197+
1198+ The material should stay relatively balanced and move between basic and more
1199+ advanced concepts in as natural a manner as possible. The goal is for a user to
1200+ read the material without having to spend too much effort trying to understand
1201+ the examples. Deep dives into one feature set should usually live elsewhere and
1202+ be linked as further reading when appropriate.
1203+
1204+ .. note ::
1205+
1206+ The user's guide contains some older material that was ported over from
1207+ Tutorials, so some of the content may not yet conform to the suggestions
1208+ above.
1209+
1210+
1211+ Examples gallery guidelines
1212+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^
11471213
11481214The gallery of examples contains visual demonstrations of matplotlib features. Gallery
11491215examples 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
11571223related concepts.
11581224
11591225Format
1160- ^^^^^^
1226+ ~~~~~~
11611227
11621228All :ref: `examples-index ` should aim to follow these guidelines:
11631229
@@ -1198,15 +1264,36 @@ makes it easier for the reader to map which parts of code correspond to which pa
11981264the plot.
11991265
12001266Figure size
1201- ^^^^^^^^^^^
1267+ ~~~~~~~~~~~
12021268When customizing figure sizes, we aim to avoid downscaling in rendered HTML docs.
12031269The current width limit (induced by *pydata-sphinx-theme *) is 720px, i.e.
12041270``figsize=(7.2, ...) ``, or 896px if the page does not have subsections and
12051271thus does not have the "On this page" navigation on the right-hand side.
12061272
1273+ Tutorials guidelines
1274+ ^^^^^^^^^^^^^^^^^^^^
12071275
1208- Plot types guidelines
1209- ---------------------
1276+ Tutorials are step-by-step guides for learning broader workflows in more depth.
1277+ They should contain explanation and instruction, and can be more cross-cutting
1278+ than individual sections of the user's guide and more in-depth than an
1279+ example. Tutorials need not be limited to assuming basic Matplotlib knowledge,
1280+ but should clearly state the assumed level of knowledge and learning goals in
1281+ the introduction.
1282+
1283+ Long-form tutorials should be organized as a coherent narrative, with sections
1284+ that build on one another and contribute to a clear end result. Break the
1285+ material into stages with clear subsections, and make it easy for readers to see
1286+ what each section adds and when to refer to other documentation for deeper
1287+ detail on a specific feature. A table of contents may be helpful for longer
1288+ tutorials.
1289+
1290+ Formatting guidelines are the same as for Examples above. Cross-link
1291+ related documentation (e.g. user guides, gallery examples, and API entries) and
1292+ tag the page with related concepts.
1293+
1294+
1295+ Plot types gallery guidelines
1296+ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12101297
12111298The :ref: `plot_types ` gallery provides an overview of the types of visualizations that
12121299Matplotlib 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
12151302`matplotlib.axes.Axes `.
12161303
12171304Format
1218- ^^^^^^
1305+ ~~~~~~
1306+
12191307:title: Method signature with required arguments, e.g. ``plot(x, y) ``
12201308:description: In one sentence, describe the visualization that the method produces and
12211309 link to the API documentation, e.g. *Draws a bar chart. See ~Axes.bar *.
0 commit comments