问题描述
def get_geometries(*readers):
geoms = []
for reader in readers:
for record in reader.records():
geoms += [record.geometry]
return geoms
fig = plt.figure(figsize=(12,6))
proj = ccrs.PlateCarree()
ax = plt.axes(projection=proj)
ax.set_extent([100,140,15,60],crs=proj)
reader = Reader('*.shp')
geoms = get_geometries(reader)
ax.add_geometries(geoms,proj,edgecolor='black',facecolor='none',alpha=0.5)
contour = ax.contourf(gx,gy,grid_data,cmap=cmap,levels=levels,extend='both')
# mask the contour plot outside the shape file
path = Path.make_compound_path(*geos_to_path(geoms))
patch = mpatches.PathPatch(path,transform=ax.transData)
for col in contour.collections:
col.set_clip_path(patch)
但是事实证明,如果我使用set_clip_path
函数,则ax.set_extent
将无效。如果我注释了代码的最后四行,则ax.set_extent
很有用。
我想cartopy或Matplotlib有一些变化。因为这段代码以前运行良好。
谢谢
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)