# Cross line through subplots

**URL:** <https://community.plotly.com/t/cross-line-through-subplots/78455>\
**Category:** Dash Python\
**Created:** [September 11, 2023, 4:37pm UTC](https://community.plotly.com/t/cross-line-through-subplots/78455 "2023-09-11T16:37:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Sank95](https://avatars.discourse-cdn.com/v4/letter/s/8edcca/32.png) [@Sank95](https://community.plotly.com/u/Sank95)\
**Post date:** [September 11, 2023, 4:37pm UTC](https://community.plotly.com/t/cross-line-through-subplots/78455/1 "2023-09-11T16:37:41Z")

</div>

Hi everyone. How do you create cross line through subplots? I atteched example in the post below.

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/7/a/7afe6f791a62d0a2e5ed3a6b9039064fadf36099.jpeg)

---

<div class="post-metadata">

**Author:** ![AIMPED](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/aimped/32/21758_2.png) [@AIMPED](https://community.plotly.com/u/AIMPED)\
**Post date:** [September 11, 2023, 5:23pm UTC](https://community.plotly.com/t/cross-line-through-subplots/78455/2 "2023-09-11T17:23:09Z")

</div>

Hi @Sank95, I think the only way to do this is using annotations. It’s going to be cumbersome, I fear.

> **[Shapes](https://plotly.com/python/shapes/)**
>
> Over 26 examples of Shapes including changing color, size, log axes, and more in Python.

---

<div class="post-metadata">

**Author:** ![jhupiterz](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jhupiterz/32/19435_2.png) [@jhupiterz](https://community.plotly.com/u/jhupiterz)\
**Post date:** [September 11, 2023, 5:34pm UTC](https://community.plotly.com/t/cross-line-through-subplots/78455/3 "2023-09-11T17:34:15Z")

</div>

If you combine `add_hline()` to a `go.layout.Shape()` it’s not so tedious, see below example:  
It will be easier if you define your xaxis ranges though.

```auto
from plotly.subplots import make_subplots
import plotly.graph_objects as go

fig = make_subplots(rows=1, cols=2, horizontal_spacing=0)

fig.add_trace(
    go.Scatter(x=[1, 2, 3], y=[40, 50, 60]),
    row=1, col=1
)

fig.add_trace(
    go.Scatter(x=[20, 30, 40], y=[50, 60, 70]),
    row=1, col=2
)

fig.update_layout(height=600, width=800, title_text="Line across subplots",
                  yaxis2={"side": "right"}, xaxis=dict(range=[0,3.5]),
                  xaxis2=dict(range=[15,45]), showlegend=False)

fig.add_hline(y=55)
fig.add_shape(
    go.layout.Shape(
        type="line",
        yref="paper",
        xref="x",
        x0=3.5,
        y0=45,
        x1=3.5,
        y1=55,
        line=dict(color="black", width=4),
    ),row=1,col=1)

fig.show()

```

 ![Screenshot 2023-09-11 at 13.33.01](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/a/8/a81b0f798645dd5e88f0ea5935077e0e53fae96b.png)
