I have the following code to plot a histogram in Python: fig.add_trace(go.Histogram(x = df["error"], showlegend = False)) This results into a histogram similar to: Now I want to add 2 vertical lines to the plot at x = target and x = -target, to create something similar like: I currently have the following code: fig.add_trace(go.Scatter(x=[target, target], y=[0, ymax], mode='lines', name='target', line=dict(color='grey', dash='dash'), legendgroup='target', showlegend=True)) fig.add_trace(go.Scatter(x=[-target, -target], y=[0, ymax], mode='lines', name='target', line=dict(color='grey', dash='dash'), legendgroup='target', showlegend=False)) However, I am not sure how I can retrieve the required ymax value from the histogram plot. Continue reading...