different legend labels for line style and line color
2 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!