omit plot legend entries

조회 수: 36 (최근 30일)
Leonard John
Leonard John 2022년 1월 5일
댓글: Leonard John 2022년 1월 5일
Within a loop I am creating fittings for a set of data. At the same time I am plotting the fitting curves and the data set with markers. How do I prevent the markers and small dots from showing within the legend? I only want the line color for each curve fitting to show up. There is one legend entry for each fit.
Thanks in advance!

채택된 답변

Voss
Voss 2022년 1월 5일
One way is to store the handles to your lines as you create them and make a legend based on a subset of the lines:
figure();
my_lines = [];
my_lines(end+1) = plot(1:10);
hold on
my_lines(end+1) = plot(2:11);
my_lines(end+1) = plot(3:12);
legend(my_lines([1 3]),{'first' 'third'});
A similar way is to only store those handles you want to use in the legend:
figure();
my_lines = [];
my_lines(end+1) = plot(1:10);
hold on
plot(2:11);
my_lines(end+1) = plot(3:12);
legend(my_lines,{'first' 'third'});

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