Counting Axes and lines

Predict the output · Basic · §3.1 From one chart to many

This code draws the number of people entering a gym at different hours, with one line for each day. fig.axes is the list of Axes in the Figure, and ax.lines is the list of lines drawn on that Axes.

Write what the code prints when you run it.

Code

import matplotlib.pyplot as plt

hours = ["6am", "9am", "12pm", "6pm", "9pm"]
monday = [42, 18, 25, 66, 38]
saturday = [12, 35, 40, 30, 15]
sunday = [8, 30, 36, 22, 10]

fig, ax = plt.subplots()
ax.plot(hours, monday, label="Monday")
ax.plot(hours, saturday, label="Saturday")
ax.legend()
print(len(fig.axes), len(ax.lines))

fig, ax = plt.subplots()
ax.plot(hours, sunday, label="Sunday")
print(len(fig.axes), len(ax.lines))

Solve this problem in your browser

Python runs in your browser and checks your answer right away. Hints and the answer are on the problem page.