← Data Visualization learning path
Data Visualization · Module 5 of 10

Matplotlib basics

Draw charts in Python with Matplotlib.

📖 Key ideas

  1. import matplotlib.pyplot as plt.
  2. plt.plot(x, y) for lines; plt.bar(x, h) for bars; plt.scatter for points.
  3. plt.title, plt.xlabel, plt.ylabel add labels.
  4. fig, ax = plt.subplots() gives more control.
  5. plt.savefig("chart.png", dpi=150) saves the chart.
💡 Real-life example: Matplotlib is a drawing board where you place each line and label yourself.
pyplotMatplotlib's plotting interface
FigureThe whole image
AxesA single plot area
savefigSaves the chart to a file