我试着go 掉剧情的顶部和右侧的脊椎,最初try 了
# Create a figure and axis with PlateCarree projection
fig, ax = plt.subplots(figsize=(11, 6),
subplot_kw={'projection': ccrs.PlateCarree()})
ax.coastlines()
# Reintroduce spines
ax.spines['top'].set_visible(True)
ax.spines['right'].set_visible(True)
ax.set_xticks(range(-180, 181, 30), crs=ccrs.PlateCarree())
ax.set_yticks(range(-90, 91, 30), crs=ccrs.PlateCarree())
# Show the plot
plt.show()
这给了我这个数字,也就是说,它显然不起作用
然后我试着移除框架并添加我想要的两根脊椎
# Create a figure and axis with PlateCarree projection
fig, ax = plt.subplots(figsize=(11, 6),
subplot_kw={'projection': ccrs.PlateCarree(),
'frameon': False})
ax.coastlines()
# Reintroduce spines
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.set_xticks(range(-180, 181, 30), crs=ccrs.PlateCarree())
ax.set_yticks(range(-90, 91, 30), crs=ccrs.PlateCarree())
# Show the plot
plt.show()
这也不太管用-我成功地移除了框架,但无法将左侧和底部的脊椎重新放回
我确实看到了这post,但当我试图将其应用于我的代码时,
# Create a figure and axis with PlateCarree projection
fig, ax = plt.subplots(figsize=(11, 6),
subplot_kw={'projection': ccrs.PlateCarree()})
ax.coastlines()
# Reintroduce spines
ax.outline_patch.set_visible(False)
ax.spines['left'].set_visible(True)
ax.spines['bottom'].set_visible(True)
ax.set_xticks(range(-180, 181, 30), crs=ccrs.PlateCarree())
ax.set_yticks(range(-90, 91, 30), crs=ccrs.PlateCarree())
# Show the plot
plt.show()
我明白错误所在
AttributeError: 'GeoAxes' object has no attribute 'outline_patch'
当然,一定有办法实现这一点?有人知道怎么做吗?我使用的是python3.10.