필터 지우기
필터 지우기

How do I create a legend that is "disconnected" from the plotted items

조회 수: 3 (최근 30일)
Patrick Mboma
Patrick Mboma 2017년 5월 15일
댓글: Adam 2017년 5월 15일
Dear all, I have the following problem. I would like to plot various items that can take two colors, say red and blue. The color of each item depends on the sign of the numbers plotted.
In order to handle such a situation I would like to be able to create a legend with exactly two entries. The first one sets the red color to negative and the blue color to positive.
The reason I call it disconnected is because (1) there could be more than two items plotted, (2) a plot need not have items of both colors.
Ideally then I should be able to add a legend even before plotting.
Is this a problem that is solvable in matlab?
Thanks
  댓글 수: 1
Adam
Adam 2017년 5월 15일
You can use:
hasbehavior( hLine, 'legend', false );
to ensure that a given line is not picked up by the legend automatically.
In terms of the rest though it sounds more like you just want text on the plot rather than a legend.
Theoretically you could achieve this by using the above on all your actual plots and then just plot two objects out of the axis limits, one blue, one red that would appear on the legend as blue and red. It's not a nice solution though, there may be better ones.

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

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