City population

In [1]:
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

In [2]:
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

In [3]:
(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'))
Out[3]:

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