2021年2月14日日曜日

Upper and lower limit in matplotlib contourf

When the data range in matplotlib contourf does not correspond to the range of colorbar, matplotlib automatically adjust the range, even when set_clim is set manually.
(In other words, I needed a fixed colorbar regardless of the data)
The solution is set "levels" as follows;

interval = np.linspace(2.5,4.5, num=32, endpoint=True)
img=plt.contourf(LON, LAT, DATA,
vmin=2.5,vmax=4.5,
cmap = "jet",
levels=interval,
transform=ccrs.PlateCarree())

0 件のコメント:

コメントを投稿