@@ -7,10 +7,11 @@ Pyplot tutorial
77:mod: `matplotlib.pyplot ` is a collection of command style functions
88that make matplotlib work like MATLAB.
99Each ``pyplot `` function makes
10- some change to a figure: e.g., create a figure, create a plotting area
11- in a figure, plot some lines in a plotting area, decorate the plot
12- with labels, etc.... :mod: `matplotlib.pyplot ` is stateful, in that it
13- keeps track of the current figure and plotting area, and the plotting
10+ some change to a figure: e.g., creates a figure, creates a plotting area
11+ in a figure, plots some lines in a plotting area, decorates the plot
12+ with labels, etc. In :mod: `matplotlib.pyplot ` various states are preserved
13+ across function calls, so that it keeps track of things like
14+ the current figure and plotting area, and the plotting
1415functions are directed to the current axes (please note that "axes" here
1516and in most places in the documentation refers to the *axes *
1617`part of a figure <http://matplotlib.org/faq/usage_faq.html#parts-of-a-figure >`__
@@ -31,7 +32,7 @@ same length as y but starts with 0. Hence the x data are
3132an arbitrary number of arguments. For example, to plot x versus y,
3233you can issue the command::
3334
34- plt.plot([1,2,3, 4], [1,4,9, 16])
35+ plt.plot([1, 2, 3, 4], [1, 4, 9, 16])
3536
3637For every x, y pair of arguments, there is an optional third argument
3738which is the format string that indicates the color and line type of
@@ -73,10 +74,11 @@ several ways to set line properties
7374 plt.plot(x, y, linewidth=2.0)
7475
7576
76- * Use the setter methods of the ``Line2D `` instance. ``plot `` returns a list
77- of lines; e.g., ``line1, line2 = plot(x1,y1,x2,y2) ``. Below I have only
78- one line so it is a list of length 1. I use tuple unpacking in the
79- ``line, = plot(x, y, 'o') `` to get the first element of the list::
77+ * Use the setter methods of a ``Line2D `` instance. ``plot `` returns a list
78+ of ``Line2D `` objects; e.g., ``line1, line2 = plot(x1, y1, x2, y2) ``. In the code
79+ below we will suppose that we have only
80+ one line so that the list returned is of length 1. We use tuple unpacking with
81+ ``line, `` to get the first element of that list::
8082
8183 line, = plt.plot(x, y, '-')
8284 line.set_antialiased(False) # turn off antialising
@@ -139,7 +141,7 @@ as argument
139141
140142.. sourcecode :: ipython
141143
142- In [69]: lines = plt.plot([1,2, 3])
144+ In [69]: lines = plt.plot([1, 2, 3])
143145
144146 In [70]: plt.setp(lines)
145147 alpha: float
@@ -172,14 +174,14 @@ will be created by default if you don't manually specify any axes. The
172174numcols, fignum `` where ``fignum `` ranges from 1 to
173175``numrows*numcols ``. The commas in the ``subplot `` command are
174176optional if ``numrows*numcols<10 ``. So ``subplot(211) `` is identical
175- to ``subplot(2,1, 1) ``. You can create an arbitrary number of subplots
177+ to ``subplot(2, 1, 1) ``. You can create an arbitrary number of subplots
176178and axes. If you want to place an axes manually, i.e., not on a
177179rectangular grid, use the :func: `~matplotlib.pyplot.axes ` command,
178180which allows you to specify the location as ``axes([left, bottom,
179181width, height]) `` where all values are in fractional (0 to 1)
180182coordinates. See :ref: `pylab_examples-axes_demo ` for an example of
181183placing axes manually and :ref: `pylab_examples-subplots_demo ` for an
182- example with lots-o- subplots.
184+ example with lots of subplots.
183185
184186
185187You can create multiple figures by using multiple
@@ -190,25 +192,26 @@ as your heart desires::
190192 import matplotlib.pyplot as plt
191193 plt.figure(1) # the first figure
192194 plt.subplot(211) # the first subplot in the first figure
193- plt.plot([1,2, 3])
195+ plt.plot([1, 2, 3])
194196 plt.subplot(212) # the second subplot in the first figure
195- plt.plot([4,5, 6])
197+ plt.plot([4, 5, 6])
196198
197199
198200 plt.figure(2) # a second figure
199- plt.plot([4,5, 6]) # creates a subplot(111) by default
201+ plt.plot([4, 5, 6]) # creates a subplot(111) by default
200202
201203 plt.figure(1) # figure 1 current; subplot(212) still current
202204 plt.subplot(211) # make subplot(211) in figure1 current
203- plt.title('Easy as 1,2, 3') # subplot 211 title
205+ plt.title('Easy as 1, 2, 3') # subplot 211 title
204206
205207You can clear the current figure with :func: `~matplotlib.pyplot.clf `
206208and the current axes with :func: `~matplotlib.pyplot.cla `. If you find
207- this statefulness, annoying, don't despair, this is just a thin
209+ it annoying that states (specifically the current image, figure and axes)
210+ are being maintained for you behind the scenes, don't despair: this is just a thin
208211stateful wrapper around an object oriented API, which you can use
209212instead (see :ref: `artist-tutorial `)
210213
211- If you are making a long sequence of figures, you need to be aware of one
214+ If you are making lots of figures, you need to be aware of one
212215more thing: the memory required for a figure is not completely
213216released until the figure is explicitly closed with
214217:func: `~matplotlib.pyplot.close `. Deleting all references to the
@@ -266,7 +269,7 @@ Annotating text
266269---------------
267270
268271The uses of the basic :func: `~matplotlib.pyplot.text ` command above
269- place text at an arbitrary position on the Axes. A common use case of
272+ place text at an arbitrary position on the Axes. A common use for
270273text is to annotate some feature of the plot, and the
271274:func: `~matplotlib.pyplot.annotate ` method provides helper
272275functionality to make annotations easy. In an annotation, there are
0 commit comments