我尝试将colorbar定位在设计好的位置,如下图所示(第5行水平,从第二列开始)。
下面是演示代码
import cartopy.crs as ccrs
import numpy as np
import xarray as xr
# Make some random data
annual=xr.DataArray(np.random.randint(1,100,(41,186,469)), dims=("year","y","x"), coords={"year":np.arange(1981,2022),
"y":np.linspace(29,38,186),
"x":np.linspace(-10,10,469)})
# Plotting
proj=ccrs.PlateCarree()
fig=annual.plot(col="year",col_wrap=10, cmap="Spectral", vmin=1, vmax=105,
subplot_kws={"projection":proj, "aspect":2.5})
# Increase title size
years=[f"Year = {i}" for i in range(1981,2022)]
for ax, year in zip(fig.axes.flatten(), years):
ax.set_title(year,fontsize=15)
ax.set_extent([-10, 10, 29, 38])
ax.coastlines(linewidth=0.5)
fig.cbar.ax.tick_params(labelsize=30)
fig.cbar.set_label(label='Label', size=30, weight='bold')
1条答案
按热度按时间3htmauhk1#
我觉得你要找的是