I am trying to make a choropleth map that has a slider so that it I can look at different years. The map, slider, and side bar for the values appear but, there is not color on the map. Also when I use the slider the side bar values disappear. Here is my code.
df_summed = df_pre_2003.groupby(['StateName']) ['nAllNeonic'].sum().reset_index()
yrs=['1992', '1993', '1994','1995','1996',
'1997', '1998', '1999', '2000', '2001','2002','2003']
data = dict(type = 'choropleth',
locations = df_summed.StateName,
locationmode = 'USA-states',
z = df_summed.nAllNeonic,
text = df_summed.StateName,
colorbar = {'title':'Neonics'},
)
steps = []
year = 0
for i in range (0,len(data)):
step = dict(method = "restyle",
args = ["visible", [False]*len(data)],
label = yrs[year])
step['args'][1][i] = True
steps.append(step)
year += 2
sliders = [dict(active = 10,
currentvalue = {"prefix": "Year: "},
pad = {"t": 50},
steps = steps)]
layout = dict(title = 'Neonic Usage 2003 and before',
geo = dict(showframe = False,
projection = {'type': 'albers usa'}),
sliders=sliders)
#fig = dict(data=data, layout=layout)
#iplot(fig)
choromap3 = go.Figure(data = [data], layout=layout)
iplot(choromap3)
The output is:
Here is what I am talking about when the side values disappear.