You are reading documentation for the unreleased version of Matplotlib. Try searching for the released version of this page instead?
Version 3.0.0rc1.post685+ga2d2b80d9
matplotlib
Fork me on GitHub

Table of Contents

API Overview

Below we describe several common approaches to plotting with Matplotlib.

The pyplot API

matplotlib.pyplot is a collection of command style functions that make Matplotlib work like MATLAB. Each pyplot function makes some change to a figure: e.g., creates a figure, creates a plotting area in a figure, plots some lines in a plotting area, decorates the plot with labels, etc.

pyplot is mainly intended for interactive plots and simple cases of programmatic plot generation.

Further reading:

The object-oriented API

At its core, Matbplotlib is object-oriented. We recommend directly working with the objects, if you need more control and customization of your plots.

In many cases you will create a Figure and one or more Axes using pyplot.subplots and from then on only work on these objects. However, it's also possible to create Figures explicitly (e.g. when including them in GUI applications).

Further reading:

The pylab API (disapproved)

Warning

Since heavily importing into the global namespace may result in unexpected behavior, the use of pylab is strongly discouraged. Use matplotlib.pyplot instead.

matplotlib.pylab is a module that includes matplotlib.pyplot, numpy and some additional functions within a single namespace. It's original puropse was to mimic a MATLAB-like way of working by importing all functions into the global namespace. This is considered bad style nowadays.