.. DO NOT EDIT. .. THIS FILE WAS AUTOMATICALLY GENERATED BY SPHINX-GALLERY. .. TO MAKE CHANGES, EDIT THE SOURCE PYTHON FILE: .. "gallery/other/plot_geomap.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_other_plot_geomap.py: Aftican cities ============== This example shows how to use ``iplotx`` with ``cartopy`` for geodata. .. tip:: This also shows that ``iplotx`` works in non-cartesian coordinate systems. .. GENERATED FROM PYTHON SOURCE LINES 10-65 .. image-sg:: /gallery/other/images/sphx_glr_plot_geomap_001.png :alt: Network of African Cities :srcset: /gallery/other/images/sphx_glr_plot_geomap_001.png :class: sphx-glr-single-img .. rst-class:: sphx-glr-script-out .. code-block:: none [] | .. code-block:: Python import matplotlib.pyplot as plt import cartopy.crs as ccrs import cartopy.feature as cfeature import networkx as nx import pandas as pd import iplotx as ipx fig = plt.figure() ax = fig.add_subplot(1, 1, 1, projection=ccrs.PlateCarree()) ax.set_extent([-20, 60, -40, 45], crs=ccrs.PlateCarree()) ax.add_feature(cfeature.LAND) ax.add_feature(cfeature.OCEAN) ax.add_feature(cfeature.COASTLINE) ax.add_feature(cfeature.BORDERS, linestyle=':') ax.add_feature(cfeature.LAKES, alpha=0.5) ax.add_feature(cfeature.RIVERS) layout = pd.read_csv( "data/african_cities_coords.csv", sep=",", index_col=0, )[["Lon", "Lat"]] g = nx.from_edgelist([ ("Tunis", "Tripoli"), ("Tripoli", "Yaoundé"), ("Yaoundé", "Kinshasa"), ("Kinshasa", "Luanda"), ("Kinshasa", "Nairobi"), ("Nairobi", "Addis Ababa"), ("Addis Ababa", "Khartoum"), ("Khartoum", "Cairo"), ("Cairo", "Tunis"), ("Lusaka", "Harare"), ("Harare", "Maputo"), ("Maputo", "Pretoria"), ("Pretoria", "Luanda"), ]) ipx.network( g, layout.loc[list(g.nodes)], ax=ax, vertex_edgecolor="black", vertex_facecolor="tomato", vertex_alpha=0.8, vertex_label_color="black", vertex_size=10, title="Network of African Cities", edge_curved=True, edge_tension=1, ) .. rst-class:: sphx-glr-timing **Total running time of the script:** (0 minutes 1.757 seconds) .. _sphx_glr_download_gallery_other_plot_geomap.py: .. only:: html .. container:: sphx-glr-footer sphx-glr-footer-example .. container:: sphx-glr-download sphx-glr-download-jupyter :download:`Download Jupyter notebook: plot_geomap.ipynb ` .. container:: sphx-glr-download sphx-glr-download-python :download:`Download Python source code: plot_geomap.py ` .. container:: sphx-glr-download sphx-glr-download-zip :download:`Download zipped: plot_geomap.zip ` .. only:: html .. rst-class:: sphx-glr-signature `Gallery generated by Sphinx-Gallery `_