Skip to content

Instantly share code, notes, and snippets.

@Ayeeta
Created September 18, 2019 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Ayeeta/ed7871bdd0f6aa34bd811b4f297dde29 to your computer and use it in GitHub Desktop.
Save Ayeeta/ed7871bdd0f6aa34bd811b4f297dde29 to your computer and use it in GitHub Desktop.
visualize poverty levels on US map
states['text'] = "Poverty Estimates 2017"+"\
"+ states["POVALL_2017"].astype(str) + " " +"State:" +" \
"+ states["Area_Name"]
fig = go.Figure(data=go.Choropleth(
locations=states['State'], # Spatial coordinates
z = states["POVALL_2017"].astype(float), # Data to be color-coded
locationmode = 'USA-states', # set of locations match entries in `locations`
colorscale = 'greens',
text = states['text'],
colorbar_title = "Poverty Estimates 2017",
reversescale = True
))
fig.update_layout(
title_text= "Poverty Estimates 2017",
geo = dict(
scope='usa',
projection=go.layout.geo.Projection(type = 'albers usa'),
showlakes=True, # lakes
lakecolor='rgb(255,255,255)'),
)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment