How to draw country borders in Cartopy

Use

how-to-draw-country-borders-in-cartopy.py
import cartopy.crs as ccrs
import cartopy.feature as cf
from matplotlib import pyplot as plt
ax = plt.axes(projection = ccrs.Mercator())
# This will add borders
ax.add_feature(cf.BORDERS)

The following code shows you a minimal example of how to plot country borders (and coastlines) using cartopy:

example.py
import cartopy.crs as ccrs
import cartopy.feature as cf
ax = plt.axes(projection = ccrs.Mercator())
ax.add_feature(cf.COASTLINE)
ax.add_feature(cf.BORDERS)
# Make figure larger
plt.gcf().set_size_inches(20, 10)

# Save figure as SVG
plt.savefig("Cartopy-Borders.svg")


Check out similar posts by category: Cartopy, Geography, Python