Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit dcc3a42

Browse files
committed
Merge pull request #5147 from gcallah/master
DOC: Cleaned up text in pyplot_tutorial.rst
2 parents 948bb9b + b669a5f commit dcc3a42

File tree

1 file changed

+22
-19
lines changed

1 file changed

+22
-19
lines changed

doc/users/pyplot_tutorial.rst

Lines changed: 22 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,11 @@ Pyplot tutorial
77
:mod:`matplotlib.pyplot` is a collection of command style functions
88
that make matplotlib work like MATLAB.
99
Each ``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
1415
functions are directed to the current axes (please note that "axes" here
1516
and 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
3132
an arbitrary number of arguments. For example, to plot x versus y,
3233
you 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

3637
For every x, y pair of arguments, there is an optional third argument
3738
which 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
172174
numcols, fignum`` where ``fignum`` ranges from 1 to
173175
``numrows*numcols``. The commas in the ``subplot`` command are
174176
optional 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
176178
and axes. If you want to place an axes manually, i.e., not on a
177179
rectangular grid, use the :func:`~matplotlib.pyplot.axes` command,
178180
which allows you to specify the location as ``axes([left, bottom,
179181
width, height])`` where all values are in fractional (0 to 1)
180182
coordinates. See :ref:`pylab_examples-axes_demo` for an example of
181183
placing axes manually and :ref:`pylab_examples-subplots_demo` for an
182-
example with lots-o-subplots.
184+
example with lots of subplots.
183185

184186

185187
You 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

205207
You can clear the current figure with :func:`~matplotlib.pyplot.clf`
206208
and 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
208211
stateful wrapper around an object oriented API, which you can use
209212
instead (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
212215
more thing: the memory required for a figure is not completely
213216
released 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

268271
The 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
270273
text is to annotate some feature of the plot, and the
271274
:func:`~matplotlib.pyplot.annotate` method provides helper
272275
functionality to make annotations easy. In an annotation, there are

0 commit comments

Comments
 (0)