How to make Cartopy coastline or border lines thicker (line width)
By standard, Cartopy draws every feature with the same line width:
ax.add_feature(cf.COASTLINE)
ax.add_feature(cf.BORDERS)
We can easily increasing the line width by adding e.g. lw=2
to the ax.add_feature()
call:
ax.add_feature(cf.COASTLINE, lw=2)
ax.add_feature(cf.BORDERS)
Complete code example
This example produces the image with a wider coast line line width as shown above
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)
# Make figure larger
plt.gcf().set_size_inches(20, 10)
# Save figure as SVG
plt.savefig("Africa-Standard.svg")