City Population#

Download this notebook from GitHub (right-click to download).


import pandas as pd
import geoviews as gv

from geoviews import dim, tile_sources as gvts

gv.extension('matplotlib')

gv.output(dpi=120)

Declare data#

cities = pd.read_csv('../../assets/cities.csv', encoding="ISO-8859-1")

points = gv.Points(cities, ['Longitude', 'Latitude'], ['City', 'Population', 'Country', 'Year'],
                   group='Top 20 Cities by population in 2050').select(Year=2050).sort('Population').iloc[-20:]

Plot#

(gvts.CartoMidnight().opts(zoom=1) *
 points.opts(
    s=dim('Population')*0.00002, color='Population', cmap='viridis',
    fig_size=300, global_extent=True) *
 gv.Labels(points).opts(color='white'))
This web page was generated from a Jupyter notebook and not all interactivity will work on this website. Right click to download and run locally for full Python-backed interactivity.

Download this notebook from GitHub (right-click to download).