Skip to main content
Albero Academy

Line Plots

The workhorse chart for trends and continuous data.

Core Plot Types9 min

The line plot is Matplotlib's default and most-used chart — perfect for anything continuous or ordered, especially trends over time. ax.plot(x, y) connects the points in order.

Drawing lines

ax.plot
ax.plot(x, y) # a simple line
ax.plot(x, y, color="crimson", linewidth=2, linestyle="--")
ax.plot(x, y, marker="o") # show the data points too
ax.plot(x, y1, x, y2) # two lines in one call

When to use it

Good forNot for
Trends over timeUnordered categories (use bars)
Continuous functionsShowing individual points only (use scatter)
Comparing a few seriesMany overlapping series (gets cluttered)

Key takeaways

  1. 01ax.plot(x, y) draws a line connecting points in order — the default chart.
  2. 02Style with color, linewidth, linestyle and marker.
  3. 03Best for trends over time and continuous data.
  4. 04Lines imply order — don't use them for unordered categories.

Finished this chapter?

Mark it complete to track your progress through Matplotlib.