In [ ]:
from IPython.display import display
from bqplot import (Figure, Map, Mercator, Orthographic, ColorScale, ColorAxis,
                    AlbersUSA, topo_load, Tooltip)

Basic Map


In [ ]:
sc_geo = Mercator()
x = Map(scales={'projection': sc_geo})
fig = Figure(marks=[x], title='Basic Map Example')
display(fig)

Advanced Map and Projection


In [ ]:
sc_geo = Orthographic(scale_factor=375, center=[0, 25], rotate=(-50, 0))
x = Map(map_data=topo_load('WorldMapData.json'), scales={'projection': sc_geo}, 
        colors={682: 'Green', 356: 'Red', 643: '#0000ff', 'default_color': 'DarkOrange'})
fig = Figure(marks=[x], fig_color='deepskyblue', title='Advanced Map Example')
display(fig)

In [ ]:
sc_geo.scale = 350

Choropleth


In [ ]:
sc_geo = Mercator()
sc_c1 = ColorScale(scheme='YlOrRd')

map_styles = {'color': {643: 105., 4: 21., 398: 23., 156: 42., 124:78., 76: 98.},
              'scales': {'projection': sc_geo, 'color': sc_c1}, 'colors': {'default_color': 'Grey'}}

axis = ColorAxis(scale=sc_c1)

x = Map(map_data=topo_load('WorldMapData.json'), **map_styles)
fig = Figure(marks=[x], axes=[axis],title='Choropleth Example')
display(fig)

Alternate Map Data


In [ ]:
sc_geo = AlbersUSA()
x = Map(map_data=topo_load('USMapData.json'), 
            scales={'projection': sc_geo})
fig = Figure(marks=[x], title='US States Map Example')
display(fig)

Interactions


In [ ]:
def_tt = Tooltip(fields=['id', 'name'])
map_mark = Map(scales={'projection': Mercator()}, tooltip=def_tt)
map_mark.interactions = {'click': 'select', 'hover': 'tooltip'}
fig = Figure(marks=[map_mark], title='Interactions Example')
display(fig)