Sitemap
Data Visualization, Data Science and Python

Practical hands-on articles and tutorials about Data visualisation, Data Science, AI and other topics. Mostly in Python.

Member-only story

Matplotlib: the Object-Oriented API Explained

12 min readNov 22, 2026

--

Press enter or click to view image in full size
A stylised chart
The embedded chart is what we are aiming at

Matplotlib has been a powerhouse of the data visualization world for many years and is the standard for generating document-ready plots and charts. But it can be a little confusing to begin with; the terms used for some chart objects are a little odd, and it has two APIs.

In this article, we are going to cut through this confusion and use the Object-Oriented Matplotlib interface to generate professional-looking charts.

How everybody starts

Just about everybody’s introduction to Matplotlib will have involved a variation of the following:

plt.plot(x, y)

Where x and y are lists (or similar) and the result is a line chart.

This looks easy, but there’s something going on behind the scenes that this code hides: four objects are created:

  1. a figure object which represents the entire chart
  2. an axes object, which despite its name, is a single plotting area
  3. two axis objects which are the vertical and horizontal rulers (the 'x' and 'y' axes)
  4. an artist object which is a drawable object, for example, a plot line.

--

--

Alan Jones
Alan Jones

Written by Alan Jones

I have had many years of experience in software development and was also a university teacher. I now write about AI, data science and programming.

Data Visualization, Data Science and Python
Data Visualization, Data Science and Python

Published in Data Visualization, Data Science and Python

Practical hands-on articles and tutorials about Data visualisation, Data Science, AI and other topics. Mostly in Python.