필터 지우기
필터 지우기

different legend labels for line style and line color

조회 수: 9 (최근 30일)
Yolande Serra
Yolande Serra 2016년 12월 8일
편집: Yolande Serra 2016년 12월 8일
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개)

카테고리

Help CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by