Hi I'm currently working with a dataset of new Covid-19 cases per 100k people for every county in the US.
Dataset:
| County FIPS | Week 1 | Week 2 | Week 3 | Week 4 | ... |
|---|---|---|---|---|---|
| 01001 | 11.7390 | 11.7390 | 13.5299 | 11.7390 | |
| 01003 | 4.5835 | 9.5110 | 17.5743 | 20.2621 | |
| 01005 | 0.0000 | 9.1016 | 33.4078 | 33.4078 | |
| ... |
I was able to have a Choropleth map that captures any single week. In this case, week 4.
from urllib.request import urlopen
import json
with urlopen('https://raw.githubusercontent.com/plotly/datasets/master/geojson-counties-fips.json') as response:
counties = json.load(response)
import plotly.express as px
fig = px.choropleth(df,
geojson=counties,
locations='County FIPS',
color='Week 4',
color_continuous_scale="Viridis",
range_color=(0, 1000),
scope="usa",
labels={'cases': 'weekly cases'}
)
fig.update_layout(margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.show()
How do I create a slider that can display snapshots of each week. I assume that I need to map the slider to the value of the color attribute, but not sure how to go about this.
Thanks.
