如何仅使用PCOLORMESH绘制分类数据集的特定值
我试图绘制分类降水类型,并且我想用一个结肠座,因为阵列包括-0.99(无爆炸)或0.99(stead)。我想知道如何仅在数据等于0.99时绘制。目前,这是我正在尝试的代码,它只是绘制了我的整个地图粉红色。有更好的方法吗?
import matplotlib as mpl
from matplotlib import colors
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
proj = ccrs.LambertConformal(central_longitude=cLon,
central_latitude=cLat)
fig = plt.figure(figsize=(12,12),dpi=100) # Increase the dots per inch from default 100 to make plot easier to read
ax = fig.add_subplot(1,1,1,projection=proj)
ax.set_extent ([lonW,lonE,latS,latN])
ptype_colors_fzra = ['deeppink']
cmap_ptype_ext_fzra = mpl.colors.ListedColormap(ptype_colors_fzra)
norm_ptype_ext_fzra = mpl.colors.BoundaryNorm([0.98,1],ncolors = len(ptype_colors_fzra))
ax.contourf(lons, lats, cfzra, cmap = cmap_ptype_ext_fzra, norm = norm_ptype_ext_fzra,
transform = ccrs.PlateCarree(), zorder = 2)
This is what ends up plotting
I am trying to plot categorial precipitation type and I have a colormap I want to use as the array either includes -0.99 (no precip) or 0.99 (precip). I want to know how to only plot when the data is equal to 0.99. Currently this is the code I am trying and it is just plotting my whole map pink. Is there a better way to do this?
import matplotlib as mpl
from matplotlib import colors
import cartopy.crs as ccrs
import matplotlib.pyplot as plt
proj = ccrs.LambertConformal(central_longitude=cLon,
central_latitude=cLat)
fig = plt.figure(figsize=(12,12),dpi=100) # Increase the dots per inch from default 100 to make plot easier to read
ax = fig.add_subplot(1,1,1,projection=proj)
ax.set_extent ([lonW,lonE,latS,latN])
ptype_colors_fzra = ['deeppink']
cmap_ptype_ext_fzra = mpl.colors.ListedColormap(ptype_colors_fzra)
norm_ptype_ext_fzra = mpl.colors.BoundaryNorm([0.98,1],ncolors = len(ptype_colors_fzra))
ax.contourf(lons, lats, cfzra, cmap = cmap_ptype_ext_fzra, norm = norm_ptype_ext_fzra,
transform = ccrs.PlateCarree(), zorder = 2)
This is what ends up plotting
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论