Single trace line color changing according to x axis value

Hi,

I’ve been trying to change color of the lines connecting the last 6 points in a single trace. For example, the lines excluding those connecting the last 6 points are shown in color blue while the lines connecting the 6 points are shown in color red. Is that possible? I tried for marker color and it worked pretty well by using ‘ifelse(x<value1,“blue”,“red”)’ in marker color in trace layout. But I just couldn’t find a good solution for line color changing.

Thank you!