@@ -19,38 +19,47 @@ module in matplotlib.
1919
2020Pyplot provides a MATLAB-style state-machine interface to
2121the underlying object-oriented plotting library in matplotlib.
22+ For example, calling a plotting function from pyplot will
23+ automatically create the necessary figure and axes to achieve
24+ the desired plot. Setting a title through pyplot will automatically
25+ set the title to the current axes object.
2226
2327Pylab combines the pyplot functionality (for plotting) with the numpy
2428functionality (for mathematics and for working with arrays)
2529in a single namespace, making that namespace
26- (or environment) even more MATLAB-like. This is what you get if
27- you use the
30+ (or environment) even more MATLAB-like.
31+ For example, one can call the `sin ` and `cos ` functions just like
32+ you could in MATLAB, as well as having all the features of pyplot.
33+
34+ The pyplot interface is generally preferred for non-interactive plotting
35+ (i.e., scripting). The pylab interface is generally preferred for interactive
36+ plotting in the python shell. Note that this is what you get if you use the
2837*ipython * shell with the *-pylab * option, which imports everything
2938from pylab and makes plotting fully interactive.
3039
3140We have been gradually converting the matplotlib examples
32- from pure MATLAB-style, using "from pylab import \* ", to a preferred
41+ from pure MATLAB-style ( using "from pylab import \* ") , to a preferred
3342style in which pyplot is used for some convenience functions, either
3443pyplot or the object-oriented style is used for the remainder of the
3544plotting code, and numpy is used explicitly for numeric array operations.
3645
37- In this preferred style, the imports at the top are::
46+ In this preferred style, the imports at the top of your script are::
3847
3948 import matplotlib.pyplot as plt
4049 import numpy as np
4150
4251Then one calls, for example, np.arange, np.zeros, np.pi, plt.figure,
4352plt.plot, plt.show, etc.
4453
45- Example, pure MATLAB-style::
54+ Example in pure MATLAB-style::
4655
4756 from pylab import *
4857 x = arange(0, 10, 0.2)
4958 y = sin(x)
5059 plot(x, y)
5160 show()
5261
53- Now in preferred style, but still using pyplot interface::
62+ Now in preferred style, using the pyplot interface::
5463
5564 import matplotlib.pyplot as plt
5665 import numpy as np
@@ -59,7 +68,8 @@ Now in preferred style, but still using pyplot interface::
5968 plt.plot(x, y)
6069 plt.show()
6170
62- And using pyplot convenience functions, but object-orientation for the rest::
71+ For full control of your plots and more advanced usage, use the pyplot
72+ interface for creating figures, but then use object-orientation for the rest::
6373
6474 import matplotlib.pyplot as plt
6575 import numpy as np
@@ -70,7 +80,7 @@ And using pyplot convenience functions, but object-orientation for the rest::
7080 ax.plot(x, y)
7181 plt.show()
7282
73- So, why do all the extra typing required as one moves away from the pure
83+ So, why all the extra typing required as one moves away from the pure
7484MATLAB-style? For very simple things like this example, the only
7585advantage is educational: the wordier styles are more explicit, more
7686clear as to where things come from and what is going on. For more
0 commit comments