Skip to content

Instantly share code, notes, and snippets.

@Ayeeta
Created September 18, 2019 14:21
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/c282c7a0b42a3a23241c5ae1f0a93baa to your computer and use it in GitHub Desktop.
Save Ayeeta/c282c7a0b42a3a23241c5ae1f0a93baa to your computer and use it in GitHub Desktop.
Visualize relationship between median household income and poverty levels
# Create figure with secondary y-axis
fig = make_subplots(specs=[[{"secondary_y": True}]])
# Add traces
fig.add_trace(
go.Scatter(x=states['State'], y=states['POVALL_2017'], name="Poverty Estimates 2017"),
secondary_y=False,
)
fig.add_trace(
go.Scatter(x=states['State'], y=states['MEDHHINC_2017'], name="Median Household Income 2017"),
secondary_y=True,
)
# Add figure title
fig.update_layout(
title_text="Relationship Between Poverty Levels And Median Household Income"
)
# Set x-axis title
fig.update_xaxes(title_text="State")
# Set y-axes titles
fig.update_yaxes(title_text="Poverty Estimates 2017", secondary_y=False)
fig.update_yaxes(title_text="Median Household Income 2017", secondary_y=True)
fig.show()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment