Search code examples
matplotlibgiscartopy

Changing line width of Cartopy borders


I am trying to make a basic map of North America, but I cannot figure out how to make the line width of the coastline and the administrative border smaller. There does not seem to be a built in option for this. Is there an easy work around? Below is my code thus far.

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)

Solution

  • The widths of these lines (or any lines added by the add_feature() method) can be controlled using the linewidth keyword. The default line width is 1, using a smaller number willl produce thinner lines:

    ax.add_feature(cfeature.BORDERS, linewidth=0.5)