Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
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
You can’t perform that action at this time.