Created
September 18, 2019 14:21
-
-
Save Ayeeta/c282c7a0b42a3a23241c5ae1f0a93baa to your computer and use it in GitHub Desktop.
Visualize relationship between median household income and poverty levels
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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