# Adding an horizontal line to each trace

**URL:** <https://community.plotly.com/t/adding-an-horizontal-line-to-each-trace/7935>\
**Category:** 📊 Plotly Python\
**Created:** [January 24, 2018, 5:43pm UTC](https://community.plotly.com/t/adding-an-horizontal-line-to-each-trace/7935 "2018-01-24T17:43:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![ruhkog](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@ruhkog](https://community.plotly.com/u/ruhkog)\
**Post date:** [January 24, 2018, 5:43pm UTC](https://community.plotly.com/t/adding-an-horizontal-line-to-each-trace/7935/1 "2018-01-24T17:43:40Z")

</div>

I have rephrased my post, plus adding lines of codes:

> [@Shape - creating horizontal line - for trace, not graph](https://community.plotly.com/t/shape-creating-horizontal-line-for-trace-not-graph/7944):
>
> 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…

* * *

Assuming a graph with 4 lines, coded using the feature traces.append(), I would like to know if it is possible to add a shape on the y axis, a straight horizontal line, but for each of the four lines.

Basically, It would be a straight line on the “trace” part, not on the layout.

What I am looking to do it’s plotting the minimum of each line. So I would end up having 8 lines, 4 with my time series, and 4 horizontal lines with the minimum of each of the time series.

---

<div class="post-metadata">

**Author:** ![empet](https://avatars.discourse-cdn.com/v4/letter/e/977dab/32.png) [@empet](https://community.plotly.com/u/empet)\
**Post date:** [January 29, 2018, 6:31pm UTC](https://community.plotly.com/t/adding-an-horizontal-line-to-each-trace/7935/2 "2018-01-29T18:31:10Z")

</div>

@ruhkog Please put an image of a manual plot to understand better what are you talking about, because  
from your above presentation it’s not clear what do you mean by horizontal line for each four lines. Then we could suggest how to define the horizontal lines.

---

<div class="post-metadata">

**Author:** ![ruhkog](https://avatars.discourse-cdn.com/v4/letter/r/f4b2a3/32.png) [@ruhkog](https://community.plotly.com/u/ruhkog)\
**Post date:** [January 30, 2018, 10:06am UTC](https://community.plotly.com/t/adding-an-horizontal-line-to-each-trace/7935/3 "2018-01-30T10:06:14Z")

</div>

I changed my way of approaching the problem. I am just adding a line on the trace.append() part, and using legendgroup to make sure it stays synchronized with my main line.
