Figure and Axes under swapped names

Predict the output · Medium · §2.2 How Figure, Axes, and Axis fit together

This code deliberately unpacks the two values returned by plt.subplots() in the order ax, fig. Write what it prints when it runs.

type(value).__name__ returns only the name of the value's type (class). A Figure's axes attribute returns the Axes in that Figure as a list.

Code

import matplotlib.pyplot as plt

ax, fig = plt.subplots()
print(type(ax).__name__)
print(type(fig).__name__)
print(type(fig.xaxis).__name__)
print(len(ax.axes))

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.