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, row in enumerate(axs):
for j, ax in enumerate(row):
a.append(ax)
for i, ax in enumerate(a):
ax.set_ylabel(str(i))
which even works for nrow
or ncol == 1
.
I tried list comprehension like:
[element for tupl in tupleOfTuples for element in tupl]
but that fails if nrows
or ncols == 1