Matplotlib Documentation
The official Matplotlib docs: a quick start that explains Figures and Axes, a gallery of plot types with copyable code, and a full API reference. Most Python plotting, including seaborn and pandas' .plot(), is Matplotlib underneath, so knowing it lets you fix any chart instead of fighting it.
23.3k (matplotlib/matplotlib)
GitHub · Sept 2026
Matplotlib 3.11.2
matplotlib.org · Sept 2026
Guide
AI & Machine Learning
Matplotlib
An evening for the quick start
Beginner
Free
What Matplotlib is and why it is worth learning properly
Matplotlib is the plotting library most of scientific Python is built on. When you call df.plot() in pandas, draw a seaborn chart or show a confusion matrix from scikit-learn, Matplotlib is doing the drawing. Learning its model once means you can adjust any of those charts: move a legend, fix overlapping labels, share an axis, or save a figure at the right size for a report.
Most frustration with Matplotlib comes from mixing its two styles of code without knowing there are two. The documentation explains both clearly, and that one idea fixes most confusion.
Where to start in the docs
Start with the Quick start guide. It covers:
- the parts of a figure: the Figure, the Axes (one plot area), each Axis with its ticks, and the Artists that draw everything
- the two coding styles: the explicit object-oriented style (
fig, ax = plt.subplots()thenax.plot(...)) and the implicitpyplotstyle (plt.plot(...)) - the kinds of input data plotting functions accept
- styling lines and markers, labelling plots, adding text and annotations, legends
- axis scales, ticks and dates, colour mapped data and colour bars
- working with several Figures and Axes, including
subplot_mosaicfor uneven layouts
The docs recommend the object-oriented style for anything complicated or reusable, and pyplot for quick interactive work. Follow that advice from day one.
After the quick start, use the Plot types page to find the chart you need, the Examples gallery to copy a working starting point, and the API reference when you need every parameter of a function. The project also publishes printable cheatsheets and handouts linked from the docs.
How long it takes
An evening for the quick start if you run every example. After that you learn by doing: each new chart sends you to the gallery for a few minutes.
Prerequisites
Basic Python and a little NumPy: creating arrays and knowing what a shape is. A Jupyter notebook is the easiest place to practise, because figures show inline.
Free or paid?
Completely free and open source, like the library itself.
What you can do afterwards
Build clear line, bar, scatter and histogram charts, lay out several plots in one figure without overlaps, label and annotate them properly, and export figures as PNG for slides or SVG and PDF for reports and papers.
Common questions
Should I learn seaborn instead? Learn both. seaborn gives quick statistical charts in one line, but it returns Matplotlib objects, so you still need Matplotlib to customise them.
Why does my code behave differently from a tutorial? Many older tutorials mix plt. calls with Axes methods. Rewrite them in the object-oriented style and they become predictable.
Best for: data science and machine learning learners who need charts they can control, and anyone making figures for a report or final year project.
Ready to start?
Opens on Matplotlib in a new tab.
Stuck on something specific?
Writing only gets you so far. If you want an answer to your situation rather than the general case, book a session and we will work through it together. Sessions are free for approved Sefism members, and a few slots open each week.
Follow along
New writing, resources and project ideas land here first.