You are reading an old version of the documentation (v2.2.5). For the latest version see https://matplotlib.org/stable/
Version 2.2.5
matplotlib
Fork me on GitHub

Related Topics

The object-oriented interfaceΒΆ

A pure OO (look Ma, no pyplot!) example using the agg backend.

from matplotlib.backends.backend_agg import FigureCanvasAgg as FigureCanvas
from matplotlib.figure import Figure

fig = Figure()
# A canvas must be manually attached to the figure (pyplot would automatically
# do it).  This is done by instantiating the canvas with the figure as
# argument.
FigureCanvas(fig)
ax = fig.add_subplot(111)
ax.plot([1, 2, 3])
ax.set_title('hi mom')
ax.grid(True)
ax.set_xlabel('time')
ax.set_ylabel('volts')
fig.savefig('test')

Keywords: matplotlib code example, codex, python plot, pyplot Gallery generated by Sphinx-Gallery