omit plot legend entries

33 ビュー (過去 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'});
  1 件のコメント
Leonard John
Leonard John 2022 年 1 月 5 日
ty

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by