City population

In [1]:
import pandas as pd
import geoviews as gv
import geoviews.tile_sources as gvts

gv.extension('matplotlib')

%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.options(zoom=1) *
 points.options(
    size_index=3, color_index=3, cmap='viridis',
    s=0.0001, fig_size=300, global_extent=True
 ) *
 gv.Labels(points).options(
    color='white'
 )
)
Out[3]:

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