8000 Merge branch 'plot_directive' of github.com:mdboom/matplotlib into mi… · kaufman/matplotlib@6926044 · GitHub
[go: up one dir, main page]

Skip to content

Commit 6926044

Browse files
committed
Merge branch 'plot_directive' of github.com:mdboom/matplotlib into minor_doc_fixes
Conflicts: lib/matplotlib/sphinxext/plot_directive.py
2 parents be14152 + eecadbb commit 6926044

File tree

4 files changed

+627
-418
lines changed

4 files changed

+627
-418
lines changed

CHANGELOG

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
2011-04-01 The plot directive Sphinx extension now supports all of the
2+
features in the Numpy fork of that extension. These
3+
include doctest formatting, an 'include-source' option, and
4+
a number of new configuration options. - MGD
5+
16
2011-03-10 Update pytz version to 2011c, thanks to Simon Cross. - JKS
27

38
2011-03-06 Add standalone tests.py test runner script. - JKS

doc/devel/documenting_mpl.rst

Lines changed: 6 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -206,19 +206,6 @@ Figures can be automatically generated from scripts and included in
206206
the docs. It is not necessary to explicitly save the figure in the
207207
script, this will be done automatically at build time to ensure that
208208
the code that is included runs and produces the advertised figure.
209-
Several figures will be saved with the same basename as the filename
210-
when the documentation is generated (low and high res PNGs, a PDF).
211-
Matplotlib includes a Sphinx extension
212-
(:file:`sphinxext/plot_directive.py`) for generating the images from
213-
the python script and including either a png copy for html or a pdf
214-
for latex::
215-
216-
.. plot:: pyplots/pyplot_simple.py
217-
:include-source:
218-
219-
If the script produces multiple figures (through multiple calls to
220-
:func:`pyplot.figure`), each will be given a numbered file name and
221-
included.
222209

223210
The path should be relative to the ``doc`` directory. Any plots
224211
specific to the documentation should be added to the ``doc/pyplots``
@@ -231,8 +218,12 @@ directory. e.g.::
231218
The ``:scale:`` directive rescales the image to some percentage of the
232219
original size, though we don't recommend using this in most cases
233220
since it is probably better to choose the correct figure size and dpi
234-
in mpl and let it handle the scaling. ``:include-source:`` will
235-
present the contents of the file, marked up as source code.
221+
in mpl and let it handle the scaling.
222+
223+
Plot directive documentation
224+
''''''''''''''''''''''''''''
225+
226+
.. automodule:: matplotlib.sphinxext.plot_directive
236227

237228
Static figures
238229
--------------

doc/users/image_tutorial.rst

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ plot from the prompt.
152152
import matplotlib.pyplot as plt
153153
import matplotlib.image as mpimg
154154
import numpy as np
155-
img = mpimg.imread('_static/stinkbug.png')
155+
img = mpimg.imread('../_static/stinkbug.png')
156156
imgplot = plt.imshow(img)
157157

158158
You can also plot any numpy array - just remember that the datatype
@@ -188,7 +188,7 @@ This is array slicing. You can read more in the `Numpy tutorial <http://www.sci
188188
import matplotlib.pyplot as plt
189189
import matplotlib.image as mpimg
190190
import numpy as np
191-
img = mpimg.imread('_static/stinkbug.png')
191+
img = mpimg.imread('../_static/stinkbug.png')
192192
lum_img = img[:,:,0]
193193
plt.imshow(lum_img)
194194

@@ -207,7 +207,7 @@ object:
207207
import matplotlib.pyplot as plt
208208
import matplotlib.image as mpimg
209209
import numpy as np
210-
img = mpimg.imread('_static/stinkbug.png')
210+
img = mpimg.imread('../_static/stinkbug.png')
211211
lum_img = img[:,:,0]
212212
imgplot = plt.imshow(lum_img)
213213
imgplot.set_cmap('hot')
@@ -221,7 +221,7 @@ object:
221221
import matplotlib.pyplot as plt
222222
import matplotlib.image as mpimg
223223
import numpy as np
224-
img = mpimg.imread('_static/stinkbug.png')
224+
img = mpimg.imread('../_static/stinkbug.png')
225225
lum_img = img[:,:,0]
226226
imgplot = plt.imshow(lum_img)
227227
imgplot.set_cmap('spectral')
@@ -245,7 +245,7 @@ do that by adding color bars. It's as easy as one line:
245245
import matplotlib.pyplot as plt
246246
import matplotlib.image as mpimg
247247
import numpy as np
248-
img = mpimg.imread('_static/stinkbug.png')
248+
img = mpimg.imread('../_static/stinkbug.png')
249249
lum_img = img[:,:,0]
250250
imgplot = plt.imshow(lum_img)
251251
imgplot.set_cmap('spectral')
@@ -276,7 +276,7 @@ image data, we use the :func:`~matplotlib.pyplot.hist` function.
276276
import matplotlib.pyplot as plt
277277
import matplotlib.image as mpimg
278278
import numpy as np
279-
img = mpimg.imread('_static/stinkbug.png')
279+
img = mpimg.imread('../_static/stinkbug.png')
280280
lum_img = img[:,:,0]
281281
plt.hist(lum_img.flatten(), 256, range=(0.0,1.0), fc='black', ec='black')
282282

@@ -300,7 +300,7 @@ object.
300300
import numpy as np
301301
fig = plt.figure()
302302
a=fig.add_subplot(1,2,1)
303-
img = mpimg.imread('_static/stinkbug.png')
303+
img = mpimg.imread('../_static/stinkbug.png')
304304
lum_img = img[:,:,0]
305305
imgplot = plt.imshow(lum_img)
306306
a.set_title('Before')
@@ -343,7 +343,7 @@ and the computer has to draw in pixels to fill that space.
343343
import matplotlib.image as mpimg
344344
import numpy as np
345345
import Image
346-
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
346+
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
347347
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
348348
rsizeArr = np.asarray(rsize)
349349
lum_img = rsizeArr[:,:,0]
@@ -364,7 +364,7 @@ Let's try some others:
364364
import matplotlib.image as mpimg
365365
import numpy as np
366366
import Image
367-
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
367+
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
368368
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
369369
rsizeArr = np.asarray(rsize)
370370
lum_img = rsizeArr[:,:,0]
@@ -381,7 +381,7 @@ Let's try some others:
381381
import matplotlib.image as mpimg
382382
import numpy as np
383383
import Image
384-
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
384+
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
385385
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
386386
rsizeArr = np.asarray(rsize)
387387
lum_img = rsizeArr[:,:,0]

0 commit comments

Comments
 (0)
0