Skip to content

Instantly share code, notes, and snippets.

@hamletbatista
Created February 28, 2019 22:39
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 hamletbatista/18c94ca8ecf0748af2365b4df1f9e4fc to your computer and use it in GitHub Desktop.
Save hamletbatista/18c94ca8ecf0748af2365b4df1f9e4fc to your computer and use it in GitHub Desktop.
line_data = []
for group in grouped_data['group'].unique().tolist():
line = go.Scatter(
x = grouped_data.loc[grouped_data['group'] == group, 'ga:date'],
y = grouped_data.loc[grouped_data['group'] == group, 'ga:newUsers'],
name = group,
mode="lines"
)
line_data.append(line)
layout = go.Layout(
shapes=
[
{
'type': 'line',
'x0': "2017-12-15",
'y0': 0,
'x1': "2017-12-15",
'y1': max(grouped_data['ga:newUsers'])+200,
'line': {
'color': 'grey',
'width': .5,
},
},
{
'type': 'line',
'x0': "2018-05-15",
'y0': 0,
'x1': "2018-05-15",
'y1': max(grouped_data['ga:newUsers'])+200,
'line': {
'color': 'grey',
'width': .5,
},
}
],
annotations = [dict(
showarrow = True,
x = "2017-12-15",
y = 1000,
text = "Shopify Switch",
xanchor = "left",
ax=50,
opacity = 1
),
dict(
showarrow = True,
x = "2018-05-15",
y = 1000,
text = "???",
xanchor = "left",
ax=-50,
opacity = 1
)]
)
fig = go.Figure(data=line_data, layout=layout)
py.plot(fig, filename="base-line.html")
from IPython.display import HTML
HTML(filename="./base-line.html")
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment