-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbar_chart.py
More file actions
27 lines (18 loc) · 774 Bytes
/
bar_chart.py
File metadata and controls
27 lines (18 loc) · 774 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
"""
Spyder Editor
@author: Abhinav Bhamidipati
"""
import plotly.graph_objects as go #create figure
import plotly.express as px #create gapminded dataset
from plotly.offline import init_notebook_mode, plot
init_notebook_mode()
df = px.data.gapminder().query("country=='India'")
df2 = px.data.gapminder().query("country=='United States'")
fig = go.Figure([go.Bar(x = df['year'], y = df['gdpPercap'], marker_color = 'green', name = 'India'),
go.Bar(x = df2['year'], y = df2['gdpPercap'], marker_color = 'orange')
])
fig.update_layout(title = 'GDP per capita over years',
xaxis_title = 'yrs',
yaxis_title = 'GDP',
barmode = 'stack') #or group
plot(fig)