.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gyexamples/plot_map_france.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_gyexamples_plot_map_france.py: .. _l-map-france: Plot a map of France ==================== This example show how to leverage a function to draw a map of France. plot_map_france +++++++++++++++ Just a map of France. .. GENERATED FROM PYTHON SOURCE LINES 16-30 .. code-block:: default import sys from matplotlib import pyplot as plt from pyensae.datasource import load_french_departements from pyensae.graphhelper import plot_map_france, plot_map_france_polygon if sys.version_info[:2] >= (3, 10): ax = plot_map_france() # This instruction may introduce a segment fault. # See https://github.com/SciTools/cartopy/issues/837. ax.set_extent([-5., 10., 38., 52.]) ax.set_title('France') else: print("some issues with the installation on older version of python.") .. rst-class:: sphx-glr-script-out .. code-block:: none some issues with the installation on older version of python. .. GENERATED FROM PYTHON SOURCE LINES 31-41 .. faqref:: :title: set_extent make python crashes. Issue `Segmentation Fault from ax.set_extent() `_ explains how to fix it. :: pip uninstall shapely pip install --no-binary :all: shapely .. GENERATED FROM PYTHON SOURCE LINES 43-47 plot_map_france_polygon +++++++++++++++++++++++ Other function to draw departments in France. .. GENERATED FROM PYTHON SOURCE LINES 47-64 .. code-block:: default # loads the French departments df = load_french_departements() if sys.version_info[:2] >= (3, 10): import cartopy.crs as ccrs fig = plt.figure(figsize=(7, 7)) ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) N = float(df.shape[0]) plot_map_france_polygon( ax=ax, geometry=df['geometry'], colors=[(i / N, 1. - i / N, 1. - i / N) for i in range(df.shape[0])]) ax.set_title('France departments') else: print("some issues with the installation on older version of python.") # plt.show() .. rst-class:: sphx-glr-script-out .. code-block:: none some issues with the installation on older version of python. .. rst-class:: sphx-glr-timing **Total running time of the script:** ( 0 minutes 18.908 seconds) .. _sphx_glr_download_gyexamples_plot_map_france.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_map_france.py ` .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_map_france.ipynb ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_