Follow these steps to create a simple plot of the capital cities plotted on a map of the world using sample data:
- First, we need to load the sample data from the GeoPandas package, which contains the world geometry information:
world = geopandas.read_file(
geopandas.datasets.get_path("naturalearth_lowres")
)
- Next, we need to load the data containing the name and position of each of the capital cities of the world:
cities = geopandas.read_file(
geopandas.datasets.get_path("naturalearth_cities")
)
- Now, we can create a new figure and plot the outline of the world geometry using the polyplot routine:
fig, ax = plt.subplots()
geoplot.polyplot(world, ax=ax)
- Finally, we use the pointplot routine to add the positions of the capital cities on top of the world map. We also set the axes limits to make the whole world...