.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/miscellanea/star_shaped_boundary.py" .. LINE NUMBERS ARE GIVEN BELOW. .. only:: html .. note:: :class: sphx-glr-download-link-note :ref:`Go to the end ` to download the full example code .. rst-class:: sphx-glr-example-title .. _sphx_glr_gallery_miscellanea_star_shaped_boundary.py: 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. .. GENERATED FROM PYTHON SOURCE LINES 13-37 .. image-sg:: /gallery/miscellanea/images/sphx_glr_star_shaped_boundary_001.png :alt: star shaped boundary :srcset: /gallery/miscellanea/images/sphx_glr_star_shaped_boundary_001.png :class: sphx-glr-single-img .. code-block:: Python import matplotlib.path as mpath import matplotlib.pyplot as plt import cartopy.crs as ccrs def main(): fig = plt.figure() ax = fig.add_axes([0, 0, 1, 1], projection=ccrs.PlateCarree()) ax.coastlines() # 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, star_path.codes.copy()) # Use the star as the boundary. ax.set_boundary(star_path, transform=ccrs.PlateCarree()) plt.show() if __name__ == '__main__': main() .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 0.032 seconds) .. _sphx_glr_download_gallery_miscellanea_star_shaped_boundary.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: star_shaped_boundary.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: star_shaped_boundary.py ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_