Color change by range in line chart

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 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)