Modifying the boundary/neatline of a map in cartopyΒΆ

This example demonstrates how to modify the boundary/neatline of an axes. We construct a star with coordinates in a Plate Carree coordinate system, and use the star as the outline of the map.

Notice how changing the projection of the map represents a projected star shaped boundary.

star shaped boundary
import matplotlib.path as mpath
import matplotlib.pyplot as plt

import as ccrs

def main():
    fig = plt.figure()
    ax = fig.add_axes([0, 0, 1, 1], projection=ccrs.PlateCarree())

    # Construct a star in longitudes and latitudes.
    star_path = mpath.Path.unit_regular_star(5, 0.5)
    star_path = mpath.Path(star_path.vertices.copy() * 80,

    # Use the star as the boundary.
    ax.set_boundary(star_path, transform=ccrs.PlateCarree())

if __name__ == '__main__':

Total running time of the script: ( 0 minutes 0.040 seconds)

Gallery generated by Sphinx-Gallery