Set some legends of a line plot to invisible
11 ビュー (過去 30 日間)
古いコメントを表示
leonidas86
2018 年 8 月 9 日
コメント済み: Giuseppe Degan Di Dieco
2021 年 5 月 15 日
Hello,
I'm plotting multiple lines with the command:
line([Min Min], [minY-20 maxY+20],....);
The variables used in line are all vectors. When adding a legend to this plot Matlab adds for each line an entry in the legend box but I want to show only one entry for all lines.
How can I do this?
採用された回答
Walter Roberson
2018 年 8 月 12 日
There are multiple ways of doing this. The easiest way is to only pass one of the output handles to legend()
h = plot([Min Min], [minY-20 maxY+20],....);
legend(h(1), 'Some Legend')
Other ways include setting the IconDisplayStyle of the other handles to 'off'
https://www.mathworks.com/help/matlab/ref/matlab.graphics.primitive.line-properties.html#d119e676350
The icondisplaystyle approach can also be used in R2014a and earlier; see https://www.mathworks.com/matlabcentral/answers/406-how-do-i-skip-items-in-a-legend
1 件のコメント
Giuseppe Degan Di Dieco
2021 年 5 月 15 日
Dear Walter,
thank you for the tip.
I didn't know this setting of the Legend function.
It really helped me with a bar plot's legend too.
Best.
その他の回答 (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!