Plot Legend

조회 수: 9 (최근 30일)
Jason
Jason 2011년 4월 7일
Is there anyway to get rid of the first data with the legend() command? I just want it to show the second data, because the first data is a patch.
I have something like this:
legendtext = 'testing'
legend([repmat(' ',1,length(legendtext));legendtext], 'location', 'northeastoutside')
That code allow me to have text starting with the second data, but the symbol for the first data still show up because of it being a patch.

채택된 답변

Jiro Doke
Jiro Doke 2011년 4월 7일
If you look at the documentation for legend, there's a syntax where you can specify the handles to the graphics objects you want to create a legend for.
hPatch = patch([1 2.5 4 3 2], [2 1 2 3 3], [1 0.5 0.5]);
hold on;
hLines = plot(4*rand(5, 2));
% Create legend just for the lines
legend(hLines, 'Line 1', 'Line 2', 'Location', 'NortheastOutside');

추가 답변 (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