Black Lives Matter. Please consider donating to Black Girls Code today.

Customize the color of a line between two points in plotly.js

Hi, I am currently working on a line plot. Is it possible to customize a line’s color between two points? For example, given the script below:

<div id="test2">
    <script>
        var trace = {
            x: array[1],
            y: array[2],
            type: 'line',
            mode: 'lines+markers',
            line: { color: 'blue', width: 5 },
            marker: {color:blue, size:10}
        };

        var layout = {
            showlegend: true,
            hovermode:'closest'
        }

        data = [trace];

        Plotly.newPlot('test2', data, layout);
    </script>
</div>

The result is as follow:

I would like to customize the color between points 1 and 2 into a red color.
Can anyone advise?
thanks in advance