different legend labels for line style and line color

5 Ansichten (letzte 30 Tage)
Yolande Serra
Yolande Serra am 8 Dez. 2016
Bearbeitet: Yolande Serra am 8 Dez. 2016
I have made a plot of my data using two different data sources for the same calculation, with four lines per source. I use colors to distinguish the 4 categories and line style to distinguish the data sources (4 solid lines, 4 dashed). I tried to manipulate legend so that I could have six labels, repeating the first category (two lines, one solid one dashed) for a total of six legend labels, 4 with category labels next to colored lines and 2 with data source labels next to dashed lines of one color. However, legend will not allow me to use different labels for the same line type even though I send it 6 children, i.e.,
kids=get(gca,'children'); %returns 8 kids, all lines
legend(gca,[kids(1:4);kids(1);kids(5)],'Cat1','Cat2','Cat3','Cat4','DataSource1','DataSource2')
The result of this command is that the DataSource1 label is applied to both instances of kids(1) in the legend rather than kids(1) having a Cat1 label in the first instance and a DataSource1 label for the second listing. In older version of Matlab I used to be able to manipulate the label string once the legend was produced. It is perhaps too smart now?

Antworten (0)

Produkte

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by