plot filled rectangle and appear on legend

Hi,
I'd like to have something like that
I know that I can use rectangle function, but then it is not appearing on a legend.
Any suggestions how to solve the issue?

 채택된 답변

Walter Roberson
Walter Roberson 2020년 11월 29일

2 개 추천

Use fill() such as
fill([xmin xmax xmax xmin], [ymin ymin ymax ymax], 'facecolor', 'y')

댓글 수: 2

michael
michael 2020년 12월 13일
If I'm using the fill multiple times, how do I create a legend so that the it will appear only once?
Maybe I shall use the fill in different way?
Record the handle of one of the fill() calls. Pass only that handle to legend() (along with the handles of any other objects you do wish to legend() )

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

제품

릴리스

R14SP1

질문:

2020년 11월 29일

댓글:

2020년 12월 13일

Community Treasure Hunt

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

Start Hunting!

Translated by