In the past, as explained here, it was possible to do:
import matplotlib.pyplot as plt
fig, axes = plt.subplots(ncols=2,nrows=3, sharex=True, sharey=True)
axes = axes.flatten()
to get a flat list of axes. Now (with matplotlib 3.9.2), this gives an error:
AttributeError: 'Axes' object has no attribute 'flatten'
Apparently, the outcome of subplots
is no longer a numpy ndarray, but an Axes object.
Is there another way to flatten it?
1