Skip to content

Instantly share code, notes, and snippets.

@databyjp
Last active November 2, 2020 06:15
Show Gist options
  • Select an option

  • Save databyjp/64369d3cc8466e3fdd4347fdd165316f to your computer and use it in GitHub Desktop.

Select an option

Save databyjp/64369d3cc8466e3fdd4347fdd165316f to your computer and use it in GitHub Desktop.
# Map showing counties with typical income < 40k
tmp_df = data_df[data_df["Median_Household_Income_2018"] < 40000]
fig = px.choropleth_mapbox(tmp_df, locations="fips", color="Median_Household_Income_2018",
range_color=[0, 100000],
geojson=counties, color_continuous_scale=px.colors.diverging.RdYlBu, labels=labels)
fig.update_layout(coloraxis_colorbar=dict(
tickvals=[0, 20000, 40000, 60000, 80000, 100000],
ticktext=["0", "20k", "40k", "60k", "80k", "100k+"]
))
fig.update_layout(mapbox_style="carto-positron",
mapbox_zoom=3.9, mapbox_center={"lat": 37.0902, "lon": -95.7129},
margin={"r": 0, "t": 0, "l": 0, "b": 0})
fig.update_traces(marker=dict(line=dict(width=0.3, color="gray")))
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment