In [ ]:
import bqplot.pyplot as plt
from bqplot import Orthographic, ColorScale, Mercator, AlbersUSA, Tooltip
In [ ]:
fig = plt.figure(title='Basic Map')
plt.geo(map_data='WorldMap')
fig
In [ ]:
fig = plt.figure(title='Advanced Map')
geo_scale = Orthographic(scale_factor=375, center=[0, 25], rotate=(-50, 0))
plt.scales(scales={'projection': geo_scale})
map_mark = plt.geo(map_data='WorldMap',
colors={682: 'Green', 356: 'Red', 643: '#0000ff', 'default_color': 'DarkOrange'})
fig
In [ ]:
geo_scale.scale = 350
In [ ]:
fig = plt.figure(title='Choropleth')
plt.scales(scales={'projection': Mercator(), 'color': ColorScale(scheme='YlOrRd')})
chloro_map = plt.geo(map_data='WorldMap',
color={643: 105., 4: 21., 398: 23., 156: 42., 124:78., 76: 98.},
colors={'default_color': 'Grey'})
fig
In [ ]:
fig = plt.figure(title='US States Map')
plt.scales(scales={'projection': AlbersUSA()})
states_map = plt.geo(map_data='USStatesMap')
fig
In [ ]:
fig = plt.figure(title='Europe Countries Map')
plt.scales(scales={'projection': Mercator(scale_factor=450)})
euro_map = plt.geo(map_data='EuropeMap')
fig
In [ ]:
fig = plt.figure(title='Interactions')
def_tt = Tooltip(fields=['id', 'name'])
map_mark = plt.geo(map_data='WorldMap', tooltip=def_tt,
interactions={'click': 'select', 'hover': 'tooltip'})
fig
In [ ]:
# clicking on any country will update the 'selected' attribute of map_mark
map_mark.selected