# Plotly Y-axis "Zerolinecolor" not working?

**URL:** <https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228>\
**Category:** Dash Python\
**Tags:** question\
**Created:** [November 19, 2023, 12:20am UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228 "2023-11-19T00:20:34Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![mrel](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@mrel](https://community.plotly.com/u/mrel)\
**Post date:** [November 19, 2023, 12:20am UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228/1 "2023-11-19T00:20:34Z")

</div>

Hi everyone,

I am playing with the design of my graph and I noticed that I cannot make the zero line for Y axis visible and change colour.  
Interesting thing is that for X axis I do not have that issue.  
I was hoping that `zerolinecolor="white"` line will show white zero line for both axis, but it’s not happening.  
Screenshot and code below. Any ideas?  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/4/a/4a36a25d9195488ded91443369b3fad80136a883.png)

```auto
fig = px.bar(df_expenses, x="period", y="amount", template="plotly_dark", title="Expenses vs Salary")
    fig.add_trace(go.Scatter(x = df_salary["period"], y = df_salary["net"], name = "Net Salary"))
    fig.update_xaxes(
        title_text="Period",
        tickangle=-45,
        showgrid=False,
        zeroline=True,
        zerolinecolor="white"
    )
    fig.update_yaxes(
        title_text="Amount",
        tickprefix="zł",
        showgrid=False,
        zeroline=True,
        zerolinecolor="white"
    )

```

---

<div class="post-metadata">

**Author:** ![atharvakatre](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/atharvakatre/32/14713_2.png) [@atharvakatre](https://community.plotly.com/u/atharvakatre)\
**Post date:** [November 19, 2023, 4:35am UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228/2 "2023-11-19T04:35:11Z")

</div>

Hi @mrel,  
You actually don’t need to pass `zeroline=True` and `zerolinecolor="white"` for x\_axes. The zeroline originates from the zeroth value on the yaxis which you can see in white color overlapping the x-axis. To get a similar white color yaxis line add the below two properties to your update\_yaxis function

```auto
 showline=True,
 linecolor="white"

```

```auto
fig = px.bar(
    x=["a", "b", "c"],
    y=[20, 10, 40],
    template="plotly_dark",
    title="Expenses vs Salary",
)
fig.add_trace(go.Scatter(x=["a", "b", "c"], y=[20, 10, 40], name="Net Salary"))
fig.update_xaxes(
    title_text="Period",
    tickangle=-45,
    showgrid=False,
)
fig.update_yaxes(
    title_text="Amount",
    tickprefix="zł",
    showgrid=False,
    zeroline=True,
    zerolinecolor="white",
    showline=True,
    linecolor="white"
)
fig.show()

```

 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/1/f16d4cfe70b99d672ff4bb8e2b640ae68b53cbc0.png)

---

<div class="post-metadata">

**Author:** ![mrel](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@mrel](https://community.plotly.com/u/mrel)\
**Post date:** [November 19, 2023, 10:24am UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228/3 "2023-11-19T10:24:56Z")

</div>

It worked. Thank you, @atharvakatre .

What I noticed now is that Y and X have different width.  
It’s visible on your screenshot and here is mine.  
 ![image](https://us1.discourse-cdn.com/flex024/uploads/plot/original/3X/f/9/f993433ec2b78b8311ae5556716c7d211b76a1ce.png)

I tried adding `zerolinewidth` to X-axis but it isn’t working.

---

<div class="post-metadata">

**Author:** ![atharvakatre](https://sea2.discourse-cdn.com/flex024/user_avatar/community.plotly.com/atharvakatre/32/14713_2.png) [@atharvakatre](https://community.plotly.com/u/atharvakatre)\
**Post date:** [November 19, 2023, 12:36pm UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228/4 "2023-11-19T12:36:22Z")

</div>

@mrel  
The yaxis line width can be adjusted by using the `linewidth` property

```auto
fig.update_yaxes(
    title_text="Amount",
    tickprefix="zł",
    showgrid=False,
    zeroline=True,
    zerolinecolor="white",
    showline=True,
    linecolor="white",
    linewidth=2
)

```

---

<div class="post-metadata">

**Author:** ![mrel](https://avatars.discourse-cdn.com/v4/letter/m/d26b3c/32.png) [@mrel](https://community.plotly.com/u/mrel)\
**Post date:** [November 19, 2023, 9:03pm UTC](https://community.plotly.com/t/plotly-y-axis-zerolinecolor-not-working/80228/5 "2023-11-19T21:03:52Z")

</div>

Works. Thank you very much!
