将 shp 文件覆盖到 FacetGrid xarray 对象

问题描述 投票:0回答:1

我正在尝试将 shapefile 布局添加到 xarray 分面图的子图中。现在,它正在将其绘制在两个单独的图中,但我希望布局出现在 13 个子图的每一个上。

这是我使用过的代码:

pft = xarray.open_dataset("/home/clara/rahu_data/netcdf/jules_frac_9pft_2015_ESA_rahu.nc")
pft['frac'].loc[13,:,:]
pft = pft['frac']

f, ax = plt.subplots(figsize=(10,5))
pft.plot(x="lon", y="lat", col="type", col_wrap=5)
shpfile.plot(ax=ax, facecolor="none")

Shapefile plot

pft plot

我正在尝试将 shapefile 布局添加到 xarray 分面图的子图中。现在,它正在将其绘制在两个单独的图中,但我希望布局出现在 13 个子图的每一个上。

这是我使用过的代码:

pft = xarray.open_dataset("/home/clara/rahu_data/netcdf/jules_frac_9pft_2015_ESA_rahu.nc")
pft['frac'].loc[13,:,:]
pft = pft['frac']

f, ax = plt.subplots(figsize=(10,5))
pft.plot(x="lon", y="lat", col="type", col_wrap=5)
shpfile.plot(ax=ax, facecolor="none")
overlay shapefile facet-wrap
1个回答
0
投票

在阅读 cartopy 世界中的 shapefile 后我知道该怎么做了。

你可以尝试这样的事情:

a=pft.plot(x="lon", y="lat", col="type", col_wrap=5)

[a.axs.flatten() 中的 ax.add_feature(shpfile,zorder=1)]

© www.soinside.com 2019 - 2024. All rights reserved.