필터 지우기
필터 지우기

Set some legends of a line plot to invisible

조회 수: 12 (최근 30일)
leonidas86
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
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'
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
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 CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2012b

Community Treasure Hunt

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

Start Hunting!

Translated by