I want to put four file plots into 1 subplot figure from a loop.
I've looped some files (four data files) to extract certain data from it (e.g. latitude, longitude and aerosol optical depth), which is correctly printed, suggesting it has successfully looped over the files and extracted what I need. When I continue the loop and just plot the results, it plots four individual figures as I haven't done subplot.
When I implement some subplot code, it does a lot of things but not what I want. I want 1 subplot figure with 2 rows and 2 columns showing each file, not 4 subplot figures repeating just that 1 file for each subplot.
This is my condensed code:
for lim in mlims:
fil= ilfil + innm +'kd00' + jad +'nam'
ln= Dataset(ilfil)
longit = vn.variables['longitude'][:]
latitud = vn.variables['latitude'][:]
## etc .....
aode = var1+var2
aod=np.squeeze(aode[:,2,:,:])
lons, lats = np.meshgrid(lonitud, latatit)
x, y = map(lons, lats)
ii=[0,1,2,3]
fig, axes = plt.subplots(nrows=4, ncols=4, figsize=(2,5))
for ax,mon_index,lname in zip(axes.flatten(),ii, mnames):
axis=np.arange(0+0.025,0.5+0.025,0.025)
cs = ax.contourf(x,y,aod,axis,cmap='seismic',linewidths=1.)
cbar = map.colorbar(cs)
plt.title(AOD)
plt.show()
The code outputs this: 1 is a plot of the file but I don't want the same file to repeat in one subplot figure, and 2+ is a plot
I want it to output:
1 1 1 2 - for the first file
1 1 1 3 - second file
1 1 1 4 - third
1 1 1 5
What I'm trying to get is just: 2 3 4 5