Is there a simple/clean way to iterate an array of axis returned by subplots like
nrow = ncol = 2
a = []
fig, axs = plt.subplots(nrows=nrow, ncols=ncol)
for
I am not sure when it was added, but there is now a squeeze keyword argument. This makes sure the result is always a 2D numpy array. Turning that into a 1D array is easy:
fig, ax2d = subplots(2, 2, squeeze=False)
axli = ax2d.flatten()
Works for any number of subplots, no trick for single ax, so a little easier than the accepted answer (perhaps squeeze didn't exist yet back then).