Open-source curation · Python-first · in Spanish & English

The catalogue

Nº18 · Visualization

Matplotlib

The foundational library for visualizing data with code in Python.

Library / frameworkIntroData Scientist·Base / cross-cuttingpython

What is it?

Matplotlib is the foundational visualization library in Python: you create charts by writing code and get full control over every element of the figure (axes, colors, annotations, size). It started by mirroring MATLAB's plotting and is today the layer much of the rest of the viz ecosystem builds on.

In fact, seaborn (elegant statistical charts) and pandas' .plot() method generate Matplotlib underneath. Understanding it gives you the base to customize what those higher-level layers produce.

What is it for?

  • Visual exploration. Inside a notebook, plot a distribution, a time series, or a correlation in two lines to understand the data.
  • Figures for reports and papers. When you need an exact chart —typography, axes, legends, resolution— Matplotlib gives the millimeter control that click tools don't.
  • The base of other libraries. Customizing a seaborn or pandas chart almost always ends up going through the Matplotlib API.

When to use it / when not

Use it for programmatic visualization: exploratory charts in notebooks, reproducible figures for reports, and whenever you want fine control over the result.

Think twice for:

  • Interactive dashboards the business explores on its own in the browser: there a BI tool like Superset is the right fit — Matplotlib produces static images, not apps.
  • Quick, pretty statistical charts: seaborn (on top of Matplotlib) gives polished results with less code.
  • Web interactivity (zoom, hover, tooltips): libraries like Plotly or Altair are built for that.

Get started in 1 minute

Install Matplotlib and draw your first chart:

pip install matplotlib
import matplotlib.pyplot as plt

countries = ["PE", "CL", "CO"]
sales = [150, 80, 120]

plt.bar(countries, sales)
plt.title("Sales by country")
plt.ylabel("Amount")
plt.show()          # in a notebook the chart appears under the cell
# plt.savefig("sales.png", dpi=150)   # or save it as an image

Quick trivia — test what you just read.

How much do you know about Matplotlib?

Official documentation

The source of truth lives there. Here we orient you; the depth is up to you.

Open official docs

What to learn next

See also

Nº18 · Updated 2026-06-25