I need to plot two histograms together in Plotly, where each histogram has a line drawn where the mean is, with a label showing the mean value. My code currently draws both histograms, however I have no idea how to add a mean line with the label. Any idea?
import numpy as np
import random
from plotly.offline import download_plotlyjs, init_notebook_mode, plot, iplot
import plotly.graph_objs as go
init_notebook_mode() # run at the start of every ipython notebook
a = np.random.normal(1500, 100, 1000)
b = np.random.normal(1500, 150, 1000)
trace1 = go.Histogram(
x=a,
opacity=0.75,
histnorm='probability',
name='> 180 t/h'
)
trace2 = go.Histogram(
x=b,
opacity=0.75,
histnorm='probability',
name='< 160 t/h',
yaxis='y2'
)
data = [trace1, trace2]
layout = go.Layout(
title='title',
barmode='overlay',
xaxis=dict(
title=''
),
yaxis=dict(
title='Normalized Frequency < 160 t/h'
),
yaxis2=dict(
title='Normalized Frequency > 180 t/h',
anchor='free',
overlaying='y',
side='right',
position=1
)
)
fig = go.Figure(data=data, layout=layout)
iplot(fig)

