How To Loop Over The Axes In A Subplot
I have a loop that generates 15 images. I created a subplot(5,3): fig, axes = plt.subplots(5,3) for i in range(28,43): (...).plot(..., ax=axes[?,?]) I would like that the ima
Solution 1:
Of course you may simply calculate the numbers.
fig, axes = plt.subplots(5,3)
for i in range(28,43):
(...).plot(..., ax=axes[(i-28)//3,(i-28)%3])
But usually you would rather loop over the axes
fig, axes = plt.subplots(5,3)
for i, ax in enumerate(axes.flat):
(...).plot(..., ax=ax)
Post a Comment for "How To Loop Over The Axes In A Subplot"