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

Matlab, plot several variables with same color and only one legend

Hello,

I’m trying to plot in Matlab using the following code:

plot(t,x,’-r’, t, y, ‘:b’);
legend(‘x’,‘y’);

where y is indeed composed of several realizations of y (a matrix). This code in Matlab renders a figure with one line in red and several lines in blue. Legend is also correct, showing only two types of lines.

However, in plot.ly the figure displays several lines of a different color each. Legend is also incorrect as it shows ‘x’ for the first line, ‘y’ for the second, and 'Trace1, Trace2, …" for the next lines. What I’m doing wrong? How can i code this graph to display the way it should in plot.ly?

Thanks a lot,

Alejandro