Skip to content

Instantly share code, notes, and snippets.

@Ayeeta
Created September 11, 2019 11:55
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/dce58079fe10f4f24728e425c7fba46c to your computer and use it in GitHub Desktop.
Save Ayeeta/dce58079fe10f4f24728e425c7fba46c to your computer and use it in GitHub Desktop.
visualize international migrant destinations on a choropleth map
states['text'] = "International Migration 2018"+"\
"+ states["INTERNATIONAL_MIG_2018"].astype(str) + " " +"State:" +" \
"+ states["Area_Name"]
fig = go.Figure(data=go.Choropleth(
locations=states['State'], # Spatial coordinates
z = states["INTERNATIONAL_MIG_2018"].astype(float), # Data to be color-coded
locationmode = 'USA-states', # set of locations match entries in `locations`
colorscale = 'reds',
text = states['text'],
colorbar_title = "International Migration",
))
fig.update_layout(
title_text= "International Migration 2018",
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