0Pricing
Python Academy · Lesson

Line, Bar and Scatter Plots

Create common chart types.

Three Workhorse Charts

Most data stories are told with three chart types:

  • Line for trends over an ordered axis like time
  • Bar for comparing categories
  • Scatter for relationships between two numeric variables

Each maps to one Matplotlib method on an axes.

Line Plots

A line plot connects points in order. In Matplotlib it is ax.plot(x, y). Use it when the x-axis has a meaningful order, such as days or measurements over time.

The data behind a line is just two parallel sequences.

months = [1, 2, 3, 4, 5]
sales = [120, 150, 130, 170, 200]
for m, s in zip(months, sales):
    print('Month', m, '->', s)
print('Trend:', 'up' if sales[-1] > sales[0] else 'down')

All lessons in this course

  1. Figures and Axes
  2. Line, Bar and Scatter Plots
  3. Customizing Plots
  4. Subplots and Layouts
← Back to Python Academy