-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathline_chart.py
More file actions
29 lines (19 loc) · 864 Bytes
/
line_chart.py
File metadata and controls
29 lines (19 loc) · 864 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
28
29
# -*- coding: utf-8 -*-
"""
Created on Mon Jun 20 14:56:42 2022
@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(data = [go.Scatter(x = df['year'], y = df['lifeExp'],\
line = dict(color = 'blue', width= 4), text = df['country'], name = 'india'),
go.Scatter(x = df2['year'], y = df2['lifeExp'])
])
fig.update_layout(title='Life Expectancy over the years',
xaxis_title = 'Years',
yaxis_title = 'Life Expectancy')
plot(fig)