-
-
Save karanjagota/18db9d644a2c1c417a82d2a90a9acabf to your computer and use it in GitHub Desktop.
bar graph example with plotly for medium blogs
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
df = pd.read_csv('lf.csv') | |
df.head() | |
subset_df = df[df.year>=2010] | |
years = df.year.unique() | |
trace1 = go.Bar(x=subset_df[subset_df['country']=='india']['Lf-overall'], | |
y=years, | |
orientation='h', | |
name="India") | |
trace2 = go.Bar(x=subset_df[subset_df['country']=='usa']['Lf-overall'], | |
y=years, | |
orientation='h', | |
name="USA") | |
data = [trace1,trace2] | |
layout = go.Layout(title = 'Life Expectency Comparison between USA and India', | |
xaxis=dict(title='Life Expectency Age'), | |
yaxis=dict(title='Years'), | |
width=800, | |
height=450) | |
fig = go.Figure(data=data,layout=layout) | |
pyo.plot(fig,filename='bar.html') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment