问题描述
我正在尝试使用 xarray 和 cartopy 制作 netCDF 数据的 facetgrid/“网格”图。对于我尝试过的大多数数据、投影和布局组合,输出是合理的。
但是,在某些情况下,地图在图的四个角附近显示为小斑点,使图无法阅读(请参阅 the image pr)。我无法使用 xarray 教程数据集 air_temperature.nc
重现此行为。因此,我使用了 small sample 中的 gpcc precipitation dataset,其中确实发生了该行为。为了生成 this image,我使用了以下内容(希望接近最小的可重现示例):
# import required packages
import xarray as xr
import cartopy.crs as ccrs
# import included dataset from the directory where it is saved
file = "gpcc_sample.nc"
gpccrain = xr.open_dataarray(file)
# make the plot
proj = ccrs.PlateCarree() # the projection I'm using for the plot
pl = gpccrain.plot(col="time",col_wrap=2,transform=proj,subplot_kws={'projection': proj})
以上改编自this example in the xarray documentation。我怀疑问题可能与this xarray issue on github有关;然而,建议的修复似乎自 'box-forced' is removed in Matplotlib 3.1 起不再适用(另见:here)。如果没有 cartopy(即只有 gpccrain.plot(col="time",col_wrap=2)
),问题不会发生。我尝试为 figsize
和 aspect
参数提供合理的值,但无济于事。移除颜色条、将地图范围更改为合理的值(在 ax.set_extent()
上的 for 循环中使用 pl.axes.flat
)或更改 cbar_kwargs
似乎也没有有意义的影响。
我应该改变什么以获得合理的情节?
我通过 anaconda 在 xarray 0.16.1
上使用 cartopy 0.18.0
和 python 3.8.6
。
提前感谢您的任何建议!
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)