read the documentation: matplotlib.pyplot.subplots
pyplot.subplots()
returns a tuple fig, ax
which is unpacked in two variables using the notation
fig, axes = plt.subplots(nrows=2, ncols=2)
the code
fig = plt.figure()
axes = fig.subplots(nrows=2, ncols=2)
does not work because subplots()
is a function in pyplot
not a member of the object Figure
.