# How to show horizontal line only in first subplot

**URL:** <https://community.plotly.com/t/how-to-show-horizontal-line-only-in-first-subplot/14636>\
**Category:** 📊 Plotly Python\
**Created:** [October 16, 2018, 10:30pm UTC](https://community.plotly.com/t/how-to-show-horizontal-line-only-in-first-subplot/14636 "2018-10-16T22:30:26Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Endogen](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/endogen/32/4455_2.png) [@Endogen](https://community.plotly.com/u/Endogen)\
**Post date:** [October 16, 2018, 10:30pm UTC](https://community.plotly.com/t/how-to-show-horizontal-line-only-in-first-subplot/14636/1 "2018-10-16T22:30:26Z")

</div>

I’ve made two subplots and i want to show a horizontal line on the first subplot. But currently it’s shown on the second one. How can i change that? Here’s my code:

```
    df_volume = DataFrame(market_data["total_volumes"], columns=["DateTime", "Volume"])
    df_volume['DateTime'] = pd.to_datetime(df_volume['DateTime'], unit='ms')
    volume = go.Scattergl(
        x=df_volume.get("DateTime"),
        y=df_volume.get("Volume"),
        name="Volume"
    )

    df_price = DataFrame(market_data["prices"], columns=["DateTime", "Price"])
    df_price['DateTime'] = pd.to_datetime(df_price['DateTime'], unit='ms')
    price = go.Scattergl(
        x=df_price.get("DateTime"),
        y=df_price.get("Price"),
        yaxis="y2",
        name="Price",
        line=dict(
            color=('rgb(22, 96, 167)'),
            width=2
        )
    )

    title = f"Price of {symbol} in {vs_cur.upper()} for past {days} days"

    # TODO: How to show the shape only on first graph?

    data = [price, volume]
    layout = go.Layout(
        yaxis=dict(domain=[0, 0.20]),
        yaxis2=dict(domain=[0.25, 1]),
        title=title,
        height=600,
        width=800,
        legend=dict(orientation='h', yanchor='top', xanchor='center', y=1, x=0.5),
        shapes=[{
            'type': 'line',
            'x0': market_data["prices"][0][0],
            'y0': market_data["prices"][len(market_data["prices"])-1][1],
            'x1': market_data["prices"][len(market_data["prices"])-1][0],
            'y1': market_data["prices"][len(market_data["prices"])-1][1],
            'line': {
                'color': 'rgb(50, 171, 96)',
                'width': 1,
                'dash': 'dashdot'
            }
        }],
    )

    fig = go.Figure(data=data, layout=layout)
```

---

<div class="post-metadata">

**Author:** ![jmmease](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/jmmease/32/3706_2.png) [@jmmease](https://community.plotly.com/u/jmmease)\
**Post date:** [October 17, 2018, 9:24am UTC](https://community.plotly.com/t/how-to-show-horizontal-line-only-in-first-subplot/14636/2 "2018-10-17T09:24:15Z")

</div>

Hi @Endogen,

You can can control which axes a shape is attached to using the `xref` and `yref` properties under `layout.shape`. See [https://plot.ly/python/reference/#layout-shapes-items-shape-xref](https://plot.ly/python/reference/#layout-shapes-items-shape-xref).

I can’t tell how you made your subplot, but try setting `xref` to `'x'` and `'x2'` and `yref` to `'y'` and `'y2'` until it does what you want 🙂

Hope that helps!  
-Jon

---

<div class="post-metadata">

**Author:** ![Endogen](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/endogen/32/4455_2.png) [@Endogen](https://community.plotly.com/u/Endogen)\
**Post date:** [October 17, 2018, 9:45pm UTC](https://community.plotly.com/t/how-to-show-horizontal-line-only-in-first-subplot/14636/3 "2018-10-17T21:45:10Z")

</div>

Awesome! Thanks a lot, that worked 😃
