Skip to content

Instantly share code, notes, and snippets.

@databyjp
Created November 2, 2020 06:26
Show Gist options
  • Save databyjp/b83113b85c7838ff8c802534a423de95 to your computer and use it in GitHub Desktop.
Save databyjp/b83113b85c7838ff8c802534a423de95 to your computer and use it in GitHub Desktop.
# Merge income data & plot
county_df = county_df.join(data_df[["fips", "Median_Household_Income_2018", "POP_ESTIMATE_2018"]].set_index("fips"), on="fips", how="left")
county_df["POP_ESTIMATE_2018"].fillna(0, inplace=True)
fig = px.scatter_mapbox(county_df, lat="lat", lon="lon", color="Median_Household_Income_2018", size="POP_ESTIMATE_2018",
range_color=[40000, 70000], size_max=40,
color_continuous_scale=px.colors.diverging.RdYlBu, labels=labels
)
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.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment