# Color change by range in line chart

**URL:** <https://community.plotly.com/t/color-change-by-range-in-line-chart/17829>\
**Category:** 📊 Plotly Python\
**Created:** [January 8, 2019, 3:31pm UTC](https://community.plotly.com/t/color-change-by-range-in-line-chart/17829 "2019-01-08T15:31:07Z")\
**Posts on this page:** 1\
**Showing post:** 3

<div class="post-metadata">

**Author:** ![gridiron9999](https://avatars.discourse-cdn.com/v4/letter/g/a4c791/32.png) [@gridiron9999](https://community.plotly.com/u/gridiron9999)\
**Post date:** [January 9, 2019, 2:28pm UTC](https://community.plotly.com/t/color-change-by-range-in-line-chart/17829/3 "2019-01-09T14:28:44Z")

</div>

Dear @jmmease i used exactly the same code for another data. In some range it gives right but sometimes it does not plot it correctly

import numpy as np  
import pandas as pd  
import telebot  
import plotly.graph\_objs as go  
import [plotly.io](http://plotly.io) as pio  
import datetime as dy  
from plotly.offline import init\_notebook\_mode, iplot  
init\_notebook\_mode()

df = pd.DataFrame({‘x’: list2, ‘y’: list1})  
theshhold = 1.0

fig = go.Figure()

# Full line

fig.add\_scattergl(x=xs, y=df.y, line={‘color’: ‘black’})

# Above threshhgold

fig.add\_scattergl(x=xs, y=df.y.where(df.y \>= 50), line={‘color’: ‘red’})

fig.add\_scattergl(x = xs, y = df.y.where(df.y \<= 35), line ={‘color’ : ‘green’})

iplot(fig)

 ![Capture](https://us1.discourse-cdn.com/flex024/uploads/plot/original/2X/3/3d9660d97521190a29161be8e33bf113447a681a.jpeg)

---

_[View the full topic](https://community.plotly.com/t/color-change-by-range-in-line-chart/17829)._
