Only one legend for scenarios

I wanted to have only one legened for this scenario generated plot instead of 11 similar names over my plot. How can I do that?


t= [1; 2; 3; 4; 5; 6; 7;8; 9; 10; 11; 12]
y= rand(12,24)
plot(t,y, color="blue", linewidth=0.3, linestyle="-", marker="x", label="legend")
legend()

Plot one of them separately with the legend. And the other ones without the legend.

The idea is just I need only one “legend” to be appear for the Whole scenario generated plots. As you can see, we have 24 plots and 24 lables according to the above code. I do need only one legend for all of them. Then I do not understand what u mean ploting separetly.

I think Leandro means calling

plot(t, y[1, :], label = "legend")
plot!(t, y[2:end, :], label = "")

Alternatively, you can do:

plot(t,y, label= permutedims(["legend"; ["" for _ ∈ 1:23]]))
3 Likes

Ok! that way, it is possible with y[:,1]

with label and y[:,2:end] without label.
Thanks

1 Like