如何使 Cartopy 海岸线或边界线更粗(线宽)
默认情况下,Cartopy 以相同的线宽绘制每个特征:
cartopy_linewidth.py
ax.add_feature(cf.COASTLINE)
ax.add_feature(cf.BORDERS)我们可以通过在
ax.add_feature() 调用中添加例如 lw=2 轻松增加线宽:
cartopy_linewidth_complete.py
ax.add_feature(cf.COASTLINE, lw=2)
ax.add_feature(cf.BORDERS)完整代码示例
此示例生成上面显示的具有更宽海岸线线宽的图像
cartopy_linewidth_save_example.py
import cartopy.crs as ccrs
import cartopy.feature as cf
from matplotlib import pyplot as plt
proj = ccrs.PlateCarree()
ax = plt.axes(projection=proj)
ax.set_extent([-23, 55, -35, 40])
ax.stock_img()
ax.add_feature(cf.COASTLINE, lw=2)
ax.add_feature(cf.BORDERS)
# 使图更大
plt.gcf().set_size_inches(20, 10)
# 将图保存为 SVG
plt.savefig("Africa-Standard.svg")If this post helped you, please consider buying me a coffee or donating via PayPal to support research & publishing of new posts on TechOverflow