← Stackzilla Blog
Matplotlib: The Python Visualization Library Behind Every Data Chart
Published July 9, 2026
· 9 min read
· Python, Matplotlib, data visualization, data science, seaborn
Matplotlib is the 20-year-old Python charting library that produced the gravitational wave discovery figure and underpins seaborn, pandas plotting, and nearly every scientific chart you have seen. Created by a neuroscientist who needed free alternatives to MATLAB, it remains the foundation of Python data visualisation.
Data without visualisation is unfinished work. Numbers in a table can show you what happened. A chart shows you why it matters. Matplotlib is the library that turned Python into a platform for scientific and data visualisation — and despite being over 20 years old, it remains the foundation that nearly every Python visualisation tool is built on.
## The Origin of Matplotlib
Matplotlib was created by John D. Hunter in 2003. Hunter was a neuroscientist at the University of Chicago who needed to visualise electrocorticography (ECoG) signals — electrical activity recorded from the surface of the brain. The visualisation tools available to him required expensive proprietary software. He wanted something that behaved like MATLAB's plotting interface but ran on open-source Python.
He built Matplotlib, released it as open source, and it spread rapidly through the scientific community. Hunter died in August 2012 from complications during cancer treatment, at age 44. The scientific Python community honoured him with a dedicated memorial at the SciPy conference that year. Matplotlib is now maintained by a large community of contributors with support from NumFOCUS and is listed as one of the foundational projects of the scientific Python ecosystem alongside NumPy, SciPy, and pandas.
Matplotlib's current version as of 2024 is 3.9, and the library receives regular maintenance releases.
## How Matplotlib Is Structured
Matplotlib has two main interfaces, and understanding the difference between them avoids a significant amount of confusion for new users.
**The pyplot interface** (`matplotlib.pyplot`) provides a stateful, MATLAB-style API. Functions like `plt.plot()`, `plt.xlabel()`, and `plt.title()` operate on whatever figure is currently active. This interface is convenient for quick, interactive exploration and is the one you will see in tutorials and Jupyter Notebooks.
**The object-oriented interface** gives you explicit control over every element. You create a `Figure` object, add `Axes` objects to it, and call methods on those objects directly. This approach is more verbose but far more flexible — it is the right choice for complex multi-panel figures, embedded plots in applications, or any time you need to customise beyond what the quick interface allows.
The underlying model is a hierarchy: a **Figure** contains one or more **Axes** (individual plots), each Axes contains **Artists** (lines, patches, text, images), and rendering happens through a backend that handles the actual drawing to screen, file, or notebook.
## What Matplotlib Can Draw
Matplotlib covers virtually every standard chart type used in data analysis and scientific publishing:
**Line plots** for time series, trends, and continuous data. **Scatter plots** for showing relationships between two variables, often used in exploratory analysis and publication figures. **Bar charts and histograms** for distributions and comparisons. **Heatmaps** using `imshow()` for correlation matrices, confusion matrices, and image data. **Box plots** for showing statistical distributions across categories. **Contour plots** for visualising three-dimensional relationships in two dimensions.
For publication-quality figures, Matplotlib supports LaTeX-rendered mathematical notation in axis labels and titles, precise control over figure size in inches (for journal submission requirements), and high-resolution PNG and vector PDF output.
## Matplotlib and the Gravitational Wave Discovery
In February 2016, LIGO announced the first direct detection of gravitational waves — ripples in spacetime predicted by Einstein's general relativity in 1915, finally observed 100 years later. The signal was a chirp: two black holes, 1.3 billion light years away, spiralling into each other over a fraction of a second.
The iconic figure published in the Physical Review Letters paper showing the gravitational wave signal was created with Matplotlib. The LIGO collaboration released their analysis code as open-source Jupyter Notebooks, and those notebooks used Matplotlib to produce every figure in the paper. A single Python visualisation library was present at one of the most significant scientific discoveries of the century.
## Integration with pandas and NumPy
Matplotlib was designed to work with NumPy arrays, and pandas built direct integration on top of it. Calling `.plot()` on a pandas DataFrame or Series produces a Matplotlib figure automatically, with sensible defaults for axes labels, legends, and titles. This integration means that in many data analysis workflows, you never interact with Matplotlib directly — you call pandas plotting methods and Matplotlib handles the rendering.
For more control, you can retrieve the underlying Matplotlib `Axes` object from a pandas plot and apply any customisation you need. This two-level approach — pandas for convenience, Matplotlib for control — is how most professional data analysis code is structured.
## seaborn: The Statistical Visualisation Layer
seaborn was created by Michael Waskom as a higher-level interface built on top of Matplotlib. Where Matplotlib gives you primitive drawing operations, seaborn provides statistical chart types: pair plots, violin plots, regression plots, cluster maps, and categorical summaries.
seaborn is not a replacement for Matplotlib — it is an addition to it. Every seaborn figure is a Matplotlib figure, and you can apply Matplotlib customisation to any seaborn output. The two libraries are used together routinely: seaborn for the initial chart structure, Matplotlib for fine-grained adjustments.
## Matplotlib in the Job Market
Matplotlib proficiency is expected in data analyst, data scientist, and research scientist roles. It appears in job postings less often than pandas or scikit-learn as an explicit requirement — largely because employers assume that anyone who knows those libraries also knows Matplotlib. It is listed explicitly in roles that emphasise data communication, reporting, and scientific publishing.
For data visualisation engineering roles or positions at media organisations doing data journalism, Matplotlib is often listed alongside more modern tools like Plotly, Bokeh, and D3.js. Understanding Matplotlib makes learning those tools significantly easier, because they all share the same conceptual model of figures, axes, and rendering pipelines.
## What Comes Next
With data loaded, computed, and visualised, the next step is building predictive models. scikit-learn — the subject of the next article in this series — is the library that makes classical machine learning accessible in Python, with a consistent API that works across dozens of algorithms.
Read the full article on Stackzilla →