Matplotlib

The fundamental Python plotting library for static charts of publication quality.

ActiveBeginnerv3.11.2Matplotlib License (based on the PSF license)Scientific Computing & Data Processing Libraries

Official documentationTry the examples

Basic information

NameMatplotlib
Full nameMatplotlib
CategoryScientific Computing & Data Processing Libraries
DeveloperThe Matplotlib community (sponsored by NumFOCUS)
Release year2003
Official websitematplotlib.org
GitHub repositorymatplotlib/matplotlib
Official documentationmatplotlib.org
Package on PyPImatplotlib
LicenseMatplotlib License (based on the PSF license) (PyPI classifier)
Project statusActive Had a release in the last 12 months
Latest version11 September 2026 (version 3.11.2)
Programming languagePython
Operating systemsNot specified
Required Python version>=3.11
Difficulty levelBeginner

Data last checked: 21 November 2026 — source: PyPI JSON API (2026-11-21)

Overview

Matplotlib gives full control over every element of a chart: axes, colours, lines and annotations, and exports charts as PNG, PDF and SVG, suitable for scientific papers.

It is used to plot training and loss curves, confusion matrices, and to display images and segmentation results. Seaborn builds a simpler interface for statistical charts on top of it.

When to choose it? Choose it for static, publication-quality charts with full control.

Uses

Main uses

  • Plotting training and validation curves
  • Displaying images and masks
  • Figures for scientific papers

Scientific fields

  • All fields of scientific research
  • Data science

Suitable project types

  • Experiment result reports
  • Static analysis dashboards

Research applications

  • Preparing figures for scientific papers
  • Visualising and comparing experiment results

Charts and data visualisation

Technical features

A feature is shown as "Supported" only if it is documented in the library's official documentation; anything we have not verified is shown as "Not specified".

CPU supportSupported
GPU supportNot applicable
CUDA compatibilityNot applicable
Distributed training or computingNot applicable
Automatic differentiation (Autodiff)Not applicable
Model deploymentNot applicable
Pre-trained modelsNot applicable
Supported data typesNumPy arrays and pandas columns
Integration with other librariesNumPy, Pandas, Seaborn
Flexibility (editorial estimate)Very high
Performance (editorial estimate)Suited to static charts
Community (editorial estimate)Huge
Documentation quality (editorial estimate)Large documentation and example gallery

Installation and running

Shell
pip install matplotlib

Compatibility: Python >=3.11 — according to the package data on PyPI, checked on 21 November 2026

Installing inside a virtual environment (venv or conda) is recommended. If you need compatibility with a specific CUDA version or operating system, refer to the official documentation, because this information changes with every release.

Code examples

Examples marked "Run and tested" were actually run, with their output, test date and library versions recorded; the others need a GPU or model downloads, so they were not run in the test environment.

BeginnerPlotting and saving the training and validation curveRun and tested

Goal: Producing a publication-quality figure of the two loss curves.

Python — example.py
import matplotlib
matplotlib.use("Agg")
import matplotlib.pyplot as plt

epochs = range(1, 11)
train = [0.9, 0.7, 0.55, 0.46, 0.40, 0.36, 0.33, 0.31, 0.30, 0.29]
val = [0.95, 0.76, 0.62, 0.55, 0.51, 0.50, 0.50, 0.51, 0.53, 0.55]

fig, ax = plt.subplots(figsize=(6, 3.5))
ax.plot(epochs, train, marker="o", label="train")
ax.plot(epochs, val, marker="s", label="validation")
ax.set_xlabel("epoch"); ax.set_ylabel("loss"); ax.legend(); ax.grid(alpha=.3)
fig.tight_layout()
fig.savefig("loss.png", dpi=200)
best = min(range(len(val)), key=val.__getitem__) + 1
print("Figure saved to loss.png; best epoch on validation:", best)

Code explanation

We use the Agg backend because it needs no display, plot two curves with a legend, then save the figure as PNG at 200 dots per inch. You can save as PDF or SVG for scientific papers.

Requirements

Shell
pip install matplotlib

How to run

Save the code in a file example.py then run it:

Shell
python example.py

Output recorded during testing

Figure saved to loss.png; best epoch on validation: 6

This example was actually run and tested on 21 November 2026 on a CPU — matplotlib 3.11.2, python 3.13.18

Example page

All Matplotlib examples in the Code Explorer

Pros

  • Fine control over every detail of a chart
  • Publication-ready quality
  • Supports vector formats

Limitations

  • The API is verbose for complex charts
  • Limited interactivity compared with Plotly

References and verification

  • Package page on PyPI (source of the version, licence and release date) Checked directly

    https://pypi.org/project/matplotlib/

    Checked on: 21 November 2026 — version checked: 3.11.2 — reviewed by: the DLArabic team

  • Official website A link the package officially declares on PyPI

    https://matplotlib.org

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official documentation A link the package officially declares on PyPI

    https://matplotlib.org

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

  • Official repository A link the package officially declares on PyPI

    https://github.com/matplotlib/matplotlib

    Checked on: 21 November 2026 — reviewed by: the DLArabic team

History of verified versions

VersionRelease dateChecked on
3.11.211 September 202621 November 2026

Page information last reviewed: 21 November 2026. The description was written originally for the encyclopedia and is not copied from the official websites.

Report information that needs updating