✊🏿 Black Lives Matter. Please consider donating to Black Girls Code today.
⚾️ It's finally Baseball season! Root for the home team... & Register for our Sports Analytics Webinar!

Shape - creating horizontal line - for trace, not graph

I am looking for a way to add a horizontal line for each trace, with the mean of the trace as value.

I have looked at adding a line using ‘shape’ in the layout, but that would be for the entire graph. I am looking to have this line for each trace.

My legend would be the same: trace 1 and trace 2, but clicking on trace 1 would highlight my trace + the new trace “mean”.

I am using this code:

import datetime
import numpy as np
import pandas as pd
a = np.array([1,2,3,4,5]) 
b = np.array([1.2,2.4,3.6,4.5,5.2])
dates = [datetime.date.today() - datetime.timedelta(1),datetime.date.today() - 
datetime.timedelta(2),datetime.date.today() - datetime.timedelta(3),datetime.date.today() - 
datetime.timedelta(4),datetime.date.today() - datetime.timedelta(5)]
data_plot = []
data_plot.append(go.Scatter(
    x=dates,
    y=a,
    mode='line',
))
data_plot.append(go.Scatter(
    x=dates,
    y=b,
    mode='line',
))
layout_plot = go.Layout(
    title='plotly_forum')

fig = go.Figure(data=data_plot, layout=layout_plot)
py.plot(fig)