in jobs/desktop-mobile-mau-2020/mobile_mau/mobile_mau.py [0:0]
def create_plot(platform, y_min, y_max, actuals, forecast, plot_start_date, slice_name):
"""
Display a plot given a platform (each mobile product),
data for actuals and forecast, and slice (Global or Tier 1).
"""
main_metric_color = "#CA3524"
main_metric_color_ci = "#DDDDDD"
main_palette = [main_metric_color, main_metric_color_ci]
ci_fillcolor = "rgba(68, 68, 68, 0.2)"
ci_markercolor = "#444"
data_end_date = actuals["date"].max().date()
plotly_data = [
go.Scatter(
name="Actuals Lower Bound",
x=actuals.date,
y=actuals["low"],
showlegend=False,
line={"color": "rgba(0,0,255, 0.8)", "width": 0},
mode="lines",
marker=dict(color=ci_markercolor),
hoverlabel={"namelength": -1},
),
go.Scatter(
name="Actuals Upper Bound",
x=actuals.date,
y=actuals["high"],
showlegend=False,
line={"color": "rgba(0,0,255, 0.8)", "width": 0},
mode="lines",
marker=dict(color=ci_markercolor),
hoverlabel={"namelength": -1},
fillcolor=ci_fillcolor,
fill="tonexty",
),
go.Scatter(
name="Actuals",
x=actuals.date,
y=actuals["value"],
showlegend=True,
line={"color": "rgba(0,0,255, 0.8)"},
hoverlabel={"namelength": -1},
),
go.Scatter(
name="Credible Interval",
x=[0],
y=[0],
showlegend=True,
line={"color": ci_fillcolor, "width": 10},
mode="lines",
hoverlabel={"namelength": -1},
),
go.Scatter(
name="Previous Year Actuals",
x=actuals.date + pd.Timedelta("365 day"),
y=actuals["value"],
showlegend=True,
line={"color": "rgba(68,120,68,0.5)", "dash": "dashdot"},
hoverlabel={"namelength": -1},
),
]
if forecast is not None:
plotly_data.extend(
[
go.Scatter(
name="Forecast Lower Bound",
x=forecast.date,
y=forecast["low"],
showlegend=False,
line={"color": "rgba(0,0,255, 0.8)", "width": 0},
mode="lines",
marker=dict(color=ci_markercolor),
hoverlabel={"namelength": -1},
),
go.Scatter(
name="Forecast Upper Bound",
x=forecast.date,
y=forecast["high"],
showlegend=False,
line={"color": "rgba(0,0,255, 0.8)", "width": 0},
mode="lines",
marker=dict(color=ci_markercolor),
hoverlabel={"namelength": -1},
fillcolor=ci_fillcolor,
fill="tonexty",
),
go.Scatter(
name="Forecast",
x=forecast.date,
y=forecast["value"],
showlegend=True,
line={"color": main_palette[0], "dash": "dot"},
hoverlabel={"namelength": -1},
),
]
)
layout = go.Layout(
# autosize=force_width is None,
# width=force_width,
# height=force_height,
title="""\