import ipyleaflet
import json
import pandas as pd
from ipywidgets import link, FloatSlider
from branca.colormap import linear
geo_json_data = json.load(open('us-states.json'))
m = ipyleaflet.Map(center = (43,-100), zoom = 4)
unemployment = pd.read_csv('US_Unemployment_Oct2012.csv')
unemployment = dict(zip(unemployment['State'].tolist(), unemployment['Unemployment'].tolist()))
layer = ipyleaflet.Choropleth(
geo_data=geo_json_data,
choro_data=unemployment,
colormap=linear.YlOrRd_04,
border_color='black',
style={'fillOpacity': 0.8, 'dashArray': '5, 5'}
)
m.add_layer(layer)
m
slider = FloatSlider(min=layer.value_min, max=layer.value_max, continuous_update=False)
slider.value = layer.value_min
link((slider, 'value'), (layer, 'value_min'))
slider
linear.YlOrBr_04.to_step(10)
linear.RdBu_11
linear.GnBu_09
layer.colormap = linear.RdBu_11
layer.border_color = 'white'