Say I have a bunch of ax1,ax2,ax3... and I want to run them through a plotting function:
def plotxy(ax,x,y): x = np.array(x) y = np.array(y) ax.plot(
you can try something like this:
import matplotlib.pyplot as plt fig, axs = plt.subplots(nrows=3, ncols=2) for ax in axs.flat: plotxy(ax,x,y)
If you use plt.subplot or plt.axes you can create a list/array of axes by hand
plt.subplot
plt.axes