# Fill according to y-values

**URL:** <https://community.plotly.com/t/fill-according-to-y-values/7414>\
**Category:** 📊 Plotly Python\
**Created:** [December 20, 2017, 10:11am UTC](https://community.plotly.com/t/fill-according-to-y-values/7414 "2017-12-20T10:11:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![fseyn](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fseyn](https://community.plotly.com/u/fseyn)\
**Post date:** [December 20, 2017, 10:11am UTC](https://community.plotly.com/t/fill-according-to-y-values/7414/1 "2017-12-20T10:11:14Z")

</div>

HI all,

I was wondering how to recreate this graph (made it with paint).

 ![temp](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/6/67800b94c8a33856dd2d661377fdd8666d410b07.png)

I just want to fill one trace according to the tick-level on the y-axis. Any suggestions?

---

<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:** [December 21, 2017, 2:40pm UTC](https://community.plotly.com/t/fill-according-to-y-values/7414/2 "2017-12-21T14:40:05Z")

</div>

@fseyn Take a look at this tutorial: [https://plot.ly/python/filled-area-plots/](https://plot.ly/python/filled-area-plots/)

`fill='tozeroy` fills the area as you want.

---

<div class="post-metadata">

**Author:** ![fseyn](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fseyn](https://community.plotly.com/u/fseyn)\
**Post date:** [December 21, 2017, 3:18pm UTC](https://community.plotly.com/t/fill-according-to-y-values/7414/3 "2017-12-21T15:18:23Z")

</div>

unfortunately, this only fills in one color.

I am looking for the solution where i can color for specific values…

example values:  
x = [1,2,3,4,5,6,7,8]  
y = [3,3,3,1,1,6,6,6]  
color red in [0,2] and green in [2,5]

---

<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:** [December 21, 2017, 3:45pm UTC](https://community.plotly.com/t/fill-according-to-y-values/7414/4 "2017-12-21T15:45:47Z")

</div>

You should define three filled areas. The lower one is filled `tozeroy` and the last two  
using `tonexty`. I thought this can be deduced from the examples presented at the link I posted.

---

<div class="post-metadata">

**Author:** ![fseyn](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@fseyn](https://community.plotly.com/u/fseyn)\
**Post date:** [December 22, 2017, 1:26pm UTC](https://community.plotly.com/t/fill-according-to-y-values/7414/5 "2017-12-22T13:26:17Z")

</div>

I should indeed have been clear by the examples but apparently, it was not for me…

Thanks for the clarification. I was hoping there would be a solution like ‘tovaluey’ but indeed, a workaround fixes it.
