FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Plot directive by mdboom · Pull Request #66 · matplotlib/matplotlib · GitHub

Repository navigation

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (1) .rst  (2) No extension  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
5 changes: 5 additions & 0 deletions CHANGELOG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
2011-04-01 The plot directive Sphinx extension now supports all of the
features in the Numpy fork of that extension. These
include doctest formatting, an 'include-source' option, and
a number of new configuration options. - MGD

2011-03-10 Update pytz version to 2011c, thanks to Simon Cross. - JKS

2011-03-06 Add standalone tests.py test runner script. - JKS
Expand Down
21 changes: 6 additions & 15 deletions doc/devel/documenting_mpl.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -213,19 +213,6 @@ Figures can be automatically generated from scripts and included in
the docs. It is not necessary to explicitly save the figure in the
script, this will be done automatically at build time to ensure that
the code that is included runs and produces the advertised figure.
Several figures will be saved with the same basename as the filename
when the documentation is generated (low and high res PNGs, a PDF).
Matplotlib includes a Sphinx extension
(:file:`sphinxext/plot_directive.py`) for generating the images from
the python script and including either a png copy for html or a pdf
for latex::

.. plot:: pyplots/pyplot_simple.py
:include-source:

If the script produces multiple figures (through multiple calls to
:func:`pyplot.figure`), each will be given a numbered file name and
included.

The path should be relative to the ``doc`` directory. Any plots
specific to the documentation should be added to the ``doc/pyplots``
Expand All @@ -238,8 +225,12 @@ directory. e.g.::
The ``:scale:`` directive rescales the image to some percentage of the
original size, though we don't recommend using this in most cases
since it is probably better to choose the correct figure size and dpi
in mpl and let it handle the scaling. ``:include-source:`` will
present the contents of the file, marked up as source code.
in mpl and let it handle the scaling.

Plot directive documentation
''''''''''''''''''''''''''''

.. automodule:: matplotlib.sphinxext.plot_directive

Static figures
--------------
Expand Down
20 changes: 10 additions & 10 deletions doc/users/image_tutorial.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ plot from the prompt.
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
imgplot = plt.imshow(img)

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

Expand All @@ -207,7 +207,7 @@ object:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
lum_img = img[:,:,0]
imgplot = plt.imshow(lum_img)
imgplot.set_cmap('hot')
Expand All @@ -221,7 +221,7 @@ object:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
lum_img = img[:,:,0]
imgplot = plt.imshow(lum_img)
imgplot.set_cmap('spectral')
Expand All @@ -245,7 +245,7 @@ do that by adding color bars. It's as easy as one line:
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
lum_img = img[:,:,0]
imgplot = plt.imshow(lum_img)
imgplot.set_cmap('spectral')
Expand Down Expand Up @@ -276,7 +276,7 @@ image data, we use the :func:`~matplotlib.pyplot.hist` function.
import matplotlib.pyplot as plt
import matplotlib.image as mpimg
import numpy as np
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
lum_img = img[:,:,0]
plt.hist(lum_img.flatten(), 256, range=(0.0,1.0), fc='black', ec='black')

Expand All @@ -300,7 +300,7 @@ object.
import numpy as np
fig = plt.figure()
a=fig.add_subplot(1,2,1)
img = mpimg.imread('_static/stinkbug.png')
img = mpimg.imread('../_static/stinkbug.png')
lum_img = img[:,:,0]
imgplot = plt.imshow(lum_img)
a.set_title('Before')
Expand Down Expand Up @@ -343,7 +343,7 @@ and the computer has to draw in pixels to fill that space.
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand All @@ -364,7 +364,7 @@ Let's try some others:
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand All @@ -381,7 +381,7 @@ Let's try some others:
import matplotlib.image as mpimg
import numpy as np
import Image
img = Image.open('_static/stinkbug.png') # opens the file using PIL - it's not an array yet
img = Image.open('../_static/stinkbug.png') # opens the file using PIL - it's not an array yet
rsize = img.resize((img.size[0]/10,img.size[1]/10)) # resize the image
rsizeArr = np.asarray(rsize)
lum_img = rsizeArr[:,:,0]
Expand Down
Loading

Back | FazBrowse Home | New Git URL