|
| 1 | +API Overview |
| 2 | +============ |
| 3 | + |
| 4 | +Below we describe several common approaches to plotting with Matplotlib. |
| 5 | + |
| 6 | +.. contents:: |
| 7 | + |
| 8 | +The pyplot API |
| 9 | +-------------- |
| 10 | + |
| 11 | +`matplotlib.pyplot` is a collection of command style functions that make |
| 12 | +Matplotlib work like MATLAB. Each pyplot function makes some change to a |
| 13 | +figure: e.g., creates a figure, creates a plotting area in a figure, plots |
| 14 | +some lines in a plotting area, decorates the plot with labels, etc. |
| 15 | + |
| 16 | +`.pyplot` is mainly intended for interactive plots and simple cases of |
| 17 | +programmatic plot generation. |
| 18 | + |
| 19 | +Further reading: |
| 20 | + |
| 21 | +- The `matplotlib.pyplot` function reference |
| 22 | +- :doc:`/tutorials/introductory/pyplot` |
| 23 | +- :ref:`Pyplot examples <pyplots_examples>` |
| 24 | + |
| 25 | +The object-oriented API |
| 26 | +----------------------- |
| 27 | + |
| 28 | +At its core, Matbplotlib is object-oriented. We recommend directly working |
| 29 | +with the objects, if you need more control and customization of your plots. |
| 30 | + |
| 31 | +In many cases you will create a `.Figure` and one or more |
| 32 | +`~matplotlib.axes.Axes` using `.pyplot.subplots` and from then on only work |
| 33 | +on these objects. However, it's also possible to create `.Figure`\ s |
| 34 | +explicitly (e.g. when including them in GUI applications). |
| 35 | + |
| 36 | +Further reading: |
| 37 | + |
| 38 | +- `matplotlib.axes.Axes` and `matplotlib.figure.Figure` for an overview of |
| 39 | + plotting functions. |
| 40 | +- Most of the :ref:`examples <examples-index>` use the object-oriented approach |
| 41 | + (except for the pyplot section). |
| 42 | + |
| 43 | + |
| 44 | +The pylab API (disapproved) |
| 45 | +--------------------------- |
| 46 | + |
| 47 | +.. warning:: |
| 48 | + Since heavily importing into the global namespace may result in unexpected |
| 49 | + behavior, the use of pylab is strongly discouraged. Use `matplotlib.pyplot` |
| 50 | + instead. |
| 51 | + |
| 52 | +`matplotlib.pylab` is a module that includes `matplotlib.pyplot`, `numpy` |
| 53 | +and some additional functions within a single namespace. It's original puropse |
| 54 | +was to mimic a MATLAB-like way of working by importing all functions into the |
| 55 | +global namespace. This is considered bad style nowadays. |
0 commit comments