Skip to content

Commit c78c810

Browse files
committed
Copy edit changelog entry
1 parent 00860f8 commit c78c810

File tree

3 files changed

+34
-63
lines changed

3 files changed

+34
-63
lines changed

doc/users/next_whats_new/2018_12_03_sphinx_plot_preserve.rst

Lines changed: 0 additions & 61 deletions
This file was deleted.
Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
Caching sphinx directive figure outputs
2+
---------------------------------------
3+
4+
The new ``:outname:`` property for the Sphinx plot directive can
5+
be used to cache generated images. It is used like:
6+
7+
.. code-block:: rst
8+
9+
.. plot::
10+
:outname: stinkbug_plot
11+
12+
import matplotlib.pyplot as plt
13+
import matplotlib.image as mpimg
14+
import numpy as np
15+
img = mpimg.imread('_static/stinkbug.png')
16+
imgplot = plt.imshow(img)
17+
18+
Without ``:outname:``, the figure generated above would normally be called,
19+
e.g. :file:`docfile3-4-01.png` or something equally mysterious. With
20+
``:outname:`` the figure generated will instead be named
21+
:file:`stinkbug_plot-01.png` or even :file:`stinkbug_plot.png`. This makes it
22+
easy to understand which output image is which and, more importantly, uniquely
23+
keys output images to the code snippets that generated them.
24+
25+
Configuring the cache directory
26+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
27+
The directory that images are cached to can be configured using the
28+
``plot_cache_dir`` configuration value in the Sphinx configuration file.
29+
30+
If an image is already in ``plot_cache_dir`` when documentation is being
31+
generated, this image is copied to the build directory thereby pre-empting
32+
generation and reducing computation time in low-resource environments.

lib/matplotlib/sphinxext/plot_directive.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
is generated from a file.
8080
``:outname:`` : str
8181
If specified, the names of the generated plots will start with the
82-
value of `:outname:`. This is handy for preserving output results if
83-
code is reordered between runs. The value of `:outname:` must be
82+
value of ``:outname:``. This is handy for preserving output results if
83+
code is reordered between runs. The value of ``:outname:`` must be
8484
unique across the generated documentation.
8585
8686
Additionally, this directive supports all the options of the `image directive

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy