How can i use my while loop conditions to loop through axis of subplots. I am very new to python. I have written a code where i plot the data based on some conditions in a while loop. The code works fine for plotting individual plots but when i have to plot all in one plot like subplots, i don't know how can i index that every time one round of plotting is finished the axis index should change and the next plotting is done on different index. As in the image it can be seen, the first row is plotted and rest everything is plotted all over again as the loop has no condition to go for axis indexing. How can i achieve is that every time the value of i,j.l,m in the code is incremented, the plots should move to next row in subplot figure.[]
import matplotlib.pyplot as plt
import xarray as xr
file="/home/arjun2516/hlrn/JOBS/cy_topo_ref4hr2/OUTPUT/cy_topo_ref4hr2_av_3d.002.nc"
Data=xr.open_dataset(file)
l=150
m=300
i = 75
j = 175
while i and j < 700 and l and m < 800 :
fig,axs = plt.subplots(ncols=3, nrows=3,figsize=(20,20))
Data.zusi[i:j,75:175].plot.contourf(ax=axs[0,0])
print(i,j)
# plt.show()
Data.zusi[l:m,250:400].plot.contourf(ax=axs[0,1])
# plt.show()
Data.zusi[l:m,450:600].plot.contourf(ax=axs[0,2])
# plt.show()
i += 200
j += 200
l += 200
m += 200
print(i,j)
print('ok')
I tried to introduce a for loop inside the while loop but it was also producing same results.