8000 Plotting somewhat better explained · matplotlib/matplotlib@a91ba41 · GitHub
[go: up one dir, main page]

Skip to content

Commit a91ba41

Browse files
committed
Plotting somewhat better explained
1 parent 104d210 commit a91ba41

File tree

1 file changed

+28
-67
lines changed

1 file changed

+28
-67
lines changed

doc/devel/documenting_mpl.rst

Lines changed: 28 additions & 67 deletions
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,9 @@ Building the docs
5959
-----------------
6060

6161
The documentation sources are found in the :file:`doc/` directory in the trunk.
62-
To build the documentation in html format, cd into :file:`doc/` and run:
62+
The configuration file for Sphinx is :file:`doc/conf.py`. It controls which
63+
directories Sphinx parses, how the docs are built, and how the extensions are
64+
used. To build the documentation in html format, cd into :file:`doc/` and run:
6365

6466
.. code-block:: sh
6567
@@ -137,12 +139,12 @@ Documents can be linked with the `:doc:` directive::
137139

138140
.. code-block:: rst
139141
140-
:doc:`/faq/installing_faq`
142+
:doc:`/faq/installing_faq`
141143
142144
will link to :doc:`/faq/installing_faq`.
143145

144146
Sections can also be given reference names. For instance from the
145-
:doc:`/faq/installing_faq`:
147+
:doc:`/faq/installing_faq` link:
146148

147149
.. code-block:: rst
148150
@@ -151,7 +153,7 @@ Sections can also be given reference names. For instance from the
151153
How to completely remove Matplotlib
152154
===================================
153155
154-
Occasionally, problems with Matplotlib can be solved with a clean
156+
Occasionally, problems with Matplotlib can be solved with a clean...
155157
156158
and refer to it using the standard reference syntax:
157159

@@ -224,30 +226,33 @@ a list of all objects that can be referenced (in this case for Numpy)::
224226

225227
python -m sphinx.ext.intersphinx 'https://docs.scipy.org/doc/numpy/objects.inv'
226228

227-
.. _referring-to-mpl-docs:
229+
.. _rst-figures-and-includes
228230
229-
Referring to data files
230-
-----------------------
231+
Including figures and files
232+
---------------------------
231233

232234
In the documentation, you may want to include to a data file in the Matplotlib
233235
sources, e.g., a license file or an image file from :file:`mpl-data`,
234236
refer to it via a relative path from the document where the rst
235-
file resides, e.g.,
236-
in :file:`users/navigation_toolbar.rst`, you can refer to the image icons with::
237+
file resides,
238+
239+
Image files can directly included in pages with the ``image::`` directive.
240+
e.g., :file:`users/navigation_toolbar.rst` displays the toolbar icons
241+
with a call to a static image::
237242

238-
.. image:: ../../lib/matplotlib/mpl-data/images/subplots.png
243+
.. image:: ../_static/toolbar.png
239244

240-
In the :file:`users` subdirectory, if you want to refer to a file in the
241-
:file:`mpl-data` directory, you can use the symlink directory. For example,
242-
from :file:`customizing.rst`::
245+
as rendered on the page: :ref:`navigation-toolbar`.
243246

244-
.. literalinclude:: ../../lib/matplotlib/mpl-data/matplotlibrc
247+
Files can be included verbatim. For instance the ``matplotlibrc`` file
248+
is important for customizing Matplotlib, and is included verbatim in the
249+
tutorial in :file:`/tutorials/introductory/customizing.py`::
245250

246-
One exception to this is when referring to the examples directory. Relative
247-
paths are extremely confusing in the sphinx plot extensions, so it is easier
248-
to simply include a symlink to the files at the top doc level directory.
249-
This way, API documents like :meth:`matplotlib.pyplot.plot` can refer to the
250-
examples in a known location.
251+
.. literalinclude:: ../../_static/matplotlibrc
252+
253+
This is rendered as `/tutorials/introductory/customizing.py` (see the
254+
bottom of the page). (Note that this is in a tutorial; See
255+
:ref:`writing-examples-and-tutorials` below)
251256

252257
In the top level :file:`doc` directory we have symlinks pointing to the
253258
Matplotlib :file:`examples`:
@@ -263,37 +268,9 @@ So we can include plots from the examples dir using the symlink:
263268
264269
.. plot:: mpl_examples/pylab_examples/simple_plot.py
265270
266-
267-
`include` statements
268-
--------------------
269-
270-
Additional files can be added to the various guides by including their base
271-
file name (the .rst extension is not necessary) in the table of contents.
272-
It is also possible to include other documents through the use of an include
273-
statement, such as::
274-
275-
.. include:: ../../TODO
276-
277-
The configuration file for Sphinx is :file:`doc/conf.py`. It controls which
278-
directories Sphinx parses, how the docs are built, and how the extensions are
279-
used.
280-
281-
.. _rest-adding-figures:
282-
283-
Adding figures
284-
--------------
285-
286-
Figures in the example gallery can be referenced by te
287-
288-
There are two options for where to put the code that generates a figure. If
289-
you want to include a plot in the examples gallery, the code should be added to
290-
the :file:`examples` directory. Plots from
291-
the :file:`examples` directory can then be referenced through the symlink
292-
``mpl_examples`` in the ``doc`` directory, e.g.:
293-
294-
.. code-block:: rst
295-
296-
.. plot:: mpl_examples/lines_bars_and_markers/fill.py
271+
Note that the python script that generates the plot is referred to, rather
272+
than any plot that is created. `Sphinx Gallery`_ will provide the incorrect
273+
reference when the documentation is built.
297274

298275

299276
.. _writing-docstrings:
@@ -390,6 +367,7 @@ to keep in mind:
390367
['aitoff' | 'hammer' | 'lambert' | 'mollweide' | \
391368
'polar' | 'rectilinear'], optional
392369
The projection type of the axes.
370+
"""
393371
394372
Alternatively, you can describe the valid parameter values in a dedicated
395373
section of the docstring.
@@ -406,23 +384,6 @@ to keep in mind:
406384
lines : `~matplotlib.collections.LineCollection`
407385
408386
409-
Linking to other code
410-
---------------------
411-
To link to other methods, classes, or modules in Matplotlib you can encase
412-
the name to refer to in back ticks, for example:
413-
414-
.. code-block:: python
415-
416-
`~matplotlib.collections.LineCollection`
417-
418-
It is also possible to add links to code in Python, Numpy, Scipy, or Pandas.
419-
Sometimes it is tricky to get external Sphinx linking to work; to check that
420-
a something exists to link to the following shell command outputs a list of all
421-
objects that can be referenced (in this case for Numpy)::
422-
423-
python -m sphinx.ext.intersphinx 'https://docs.scipy.org/doc/numpy/objects.inv'
424-
425-
426387
Function arguments
427388
------------------
428389
Function arguments and keywords within docstrings should be referred to using

0 commit comments

Comments
 (0)
0