For loop Python Matplotlib添加2个动态标题组件
我有6个子地块,需要2个动态标题组件,我可以为1编码,但我不知道如何更改下面的代码,在搜索文献后在同一行添加第二个动态标题组件。下面是我的for循环,用于生成下面带有“plt.title..”行的6个子批次:For loop Python Matplotlib添加2个动态标题组件,for-loop,matplotlib,dynamic,title,For Loop,Matplotlib,Dynamic,Title,我有6个子地块,需要2个动态标题组件,我可以为1编码,但我不知道如何更改下面的代码,在搜索文献后在同一行添加第二个动态标题组件。下面是我的for循环,用于生成下面带有“plt.title..”行的6个子批次: list = [0,1,2,3,4,5] now = datetime.datetime.now() currm = now.month import calendar fig, ax = plt.subplots(6) for x in list: dam = DS.where(
list = [0,1,2,3,4,5]
now = datetime.datetime.now()
currm = now.month
import calendar
fig, ax = plt.subplots(6)
for x in list:
dam = DS.where(DS['time.year']==rmax.iloc[x,1]).groupby('time.month').mean()#iterate by index of
column "1" or the years
dam = dam.sel(month=3)#current month mean 500
dam = dam.sel(level=500)
damc = dam.to_array()
lats = damc['lat'].data
lons = damc['lon'].data
#plot data
ax = plt.axes(projection=ccrs.PlateCarree())
ax.coastlines(lw=1)
damc = damc.squeeze()
cnplot = plt.contour(lons,lats,damc,cmap='jet')
plt.title('Mean 500mb Hgt + Phase {} 2020'.format(calendar.month_name[currm-1]))
plt.show()
#plt.clf()
我需要在循环中从这个列表中分别添加一个到“+”和上面的单词“Phase”行之间的“plt.title..”
tindices = ['SOI','AO','NAO','PNA','EPO','PDO']
谢谢你在这方面的帮助 尝试逐个访问
tindies
并将其传递给标题
plt.title('Mean 500mb Hgt + {} Phase {} 2020'.format(tindices[x],
calendar.month_name[currm-1]))