The Axes array from subplots

Predict the output · Medium · §3.2 Arranging and reaching Axes

This code makes several Axes with plt.subplots() and looks at the second return value. axes.shape tells you how many rows and columns the array has, and type(…).__name__ shows the name of the object's class.

Write what the code prints when you run it.

Code

import matplotlib.pyplot as plt

fig, axes = plt.subplots(3, 2)
print(axes.shape)
print(len(fig.axes))
print(axes[2].shape)
print(type(axes[2, 1]).__name__)

fig, axes = plt.subplots(1, 3)
print(axes.shape)
axes[0, 2].set_title("Right")

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.