matplotlib, by Drawing It

Figures and axes, the two APIs, and the styling that turns a default plot into one worth showing - every example drawn on the page.

22 modules Free, no login Updated 31 August 2026

About this track

matplotlib is two libraries sharing a name: a stateful pyplot interface that draws into whatever figure is current, and an object-oriented one where you hold the figure and the axes and ask them to draw. Most confusing examples online mix the two.

This track uses the object-oriented form throughout and explains the other where you will meet it. Every editor draws a real figure and shows it under the output, so a change to a line is a change you see.

Every editor draws a real figure and shows it under the output, so changing a number and running it again is the fastest way to find out what an argument does - which matters here more than in most libraries, because matplotlib's argument names are not always guessable.

What you will be able to do

How the track is ordered

The figure and the axes come first, along with the two APIs that make most examples online confusing. Then the drawing types - lines, scatters, bars, histograms, boxes and images - followed by everything that makes a chart readable: labels, legends, limits, ticks, colour and annotation. Layout and saving come next, because a figure that looks right on screen and crops when saved is the commonest frustration. The track ends with judgement rather than mechanism - choosing a chart, the mistakes that produce a plausible wrong picture, and what to do when there are more points than pixels.

Where this leads

matplotlib is the layer under pandas' .plot and under seaborn, so anything either of those produces can be adjusted with what is here. The pandas track covers getting data into the shape a chart wants, which is usually the larger half of the work.

All 22 modules, in teaching order

  1. 01Figure and Axes
  2. 02Line Plots
  3. 03Scatter Plots
  4. 04Bar Charts
  5. 05Histograms and Distributions
  6. 06Labels, Titles and Legends
  7. 07Limits, Ticks and Scales
  8. 08Subplots
  9. 09Colour and Colormaps
  10. 10Annotating a Plot
  11. 11Saving Figures
  12. 12Dates on an Axis
  13. 13Error Bars and Bands
  14. 14Images and Heatmaps
  15. 15Styles and rcParams
  16. 16Twin and Secondary Axes
  17. 17Box and Violin Plots
  18. 18Plotting from pandas
  19. 19Choosing a Chart
  20. 20Performance and Large Data
  21. 21Layout and Spacing
  22. 22Common Mistakes

Other tracks