Deals Of The Week - hours only!Up to 80% off on all courses and bundles.-Close
Line plots
4. Adding lines to subplots
Multiple histograms
Other plot types


Great! Now that we have an empty subplot, it's time to draw some lines on it!

figure = plt.figure(figsize=(10, 6))
subplot = plt.subplot()

Line 3 means: take the Toronto column from the climate DataSeries and plot a line with its values in the subplot. A single subplot can show multiple lines – below line 3, we also added line 4 with the Barcelona data. The result looks like this:

Sample plot

You can see that matplotlib changed our x-axis and y-axis to match the lines. That's a very convenient feature.


Add three lines to the subplot:

  • The first line is for romance books.
  • The second line is for fantasy books.
  • The third line is for thriller books.

Stuck? Here's a hint!

Create the first plot with: