I like to plot two groups of lines in the same plot. Each group has two lines with same color and I have to draw them in the order of one group after another group. I try to show legend for groups only not for lines. How can I do this? Here is a simplification of my wrong code:
plot(x1, y1, color1); hold on;
plot(x2, y2, color1); hold on;
plot(x3, y3, color2); hold on;
plot(x4, y4, color2); hold on;
legend({color1, color2})
Thanks!
UPDATE:
A new question, is there any way to write legend after each line and without overwriting the previous legend but append to it? i.e. something similar to "hold on" but applied to legend.
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…