更改 Cartopy 边框的线宽

jta*_*tam 6 gis matplotlib cartopy

我正在尝试制作北美的基本地图,但我不知道如何使海岸线和行政边界的线宽变小。似乎没有为此提供内置选项。有没有简单的解决方法?以下是我迄今为止的代码。

import matplotlib.pyplot as plt
import cartopy.feature as cfeature
import cartopy.crs as ccrs

east = -63
west = -123
north = 55
south = 20
fig = plt.figure()
ax=fig.add_subplot(1,1,1,projection=ccrs.AlbersEqualArea)          
ax.set_extent([west, east, south, north])
ax.add_feature(cfeature.OCEAN)
ax.add_feature(cfeature.LAND,color='grey')
ax.add_feature(cfeature.BORDERS)
ax.add_feature(cfeature.COASTLINE)
Run Code Online (Sandbox Code Playgroud)

ajd*_*son 7

add_feature()可以使用linewidth关键字控制这些线(或由该方法添加的任何线)的宽度。默认线宽为 1,使用较小的数字将产生更细的线:

ax.add_feature(cfeature.BORDERS, linewidth=0.5)
Run Code Online (Sandbox Code Playgroud)