|
149 | 149 | # Matplotlib, pyplot and pylab: how are they related? |
150 | 150 | # ==================================================== |
151 | 151 | # |
152 | | -# Matplotlib is the whole package; :mod:`matplotlib.pyplot` |
153 | | -# is a module in matplotlib; and :mod:`pylab` is a module |
154 | | -# that gets installed alongside :mod:`matplotlib`. |
| 152 | +# Matplotlib is the whole package and :mod:`matplotlib.pyplot` is a module in |
| 153 | +# Matplotlib. |
155 | 154 | # |
156 | | -# Pyplot provides the state-machine interface to the underlying |
157 | | -# object-oriented plotting library. The state-machine implicitly and |
158 | | -# automatically creates figures and axes to achieve the desired |
159 | | -# plot. For example: |
| 155 | +# For functions in the pyplot module, there is always a "current" figure and |
| 156 | +# axes (which is created automatically on request). For example, in the |
| 157 | +# following example, the first call to ``plt.plot`` creates the axes, then |
| 158 | +# subsequent calls to ``plt.plot`` add additional lines on the same axes, and |
| 159 | +# ``plt.xlabel``, ``plt.ylabel``, ``plt.title`` and ``plt.legend`` set the |
| 160 | +# axes labels and title and add a legend. |
160 | 161 |
|
161 | 162 | x = np.linspace(0, 2, 100) |
162 | 163 |
|
|
174 | 175 | plt.show() |
175 | 176 |
|
176 | 177 | ############################################################################### |
177 | | -# The first call to ``plt.plot`` will automatically create the necessary |
178 | | -# figure and axes to achieve the desired plot. Subsequent calls to |
179 | | -# ``plt.plot`` re-use the current axes and each add another line. |
180 | | -# Setting the title, legend, and axis labels also automatically use the |
181 | | -# current axes and set the title, create the legend, and label the axis |
182 | | -# respectively. |
183 | | -# |
184 | 178 | # :mod:`pylab` is a convenience module that bulk imports |
185 | 179 | # :mod:`matplotlib.pyplot` (for plotting) and :mod:`numpy` |
186 | | -# (for mathematics and working with arrays) in a single name space. |
| 180 | +# (for mathematics and working with arrays) in a single namespace. |
187 | 181 | # pylab is deprecated and its use is strongly discouraged because |
188 | 182 | # of namespace pollution. Use pyplot instead. |
189 | 183 | # |
|
0 commit comments