How do I create a legend that is "disconnected" from the plotted items
1 回表示 (過去 30 日間)
古いコメントを表示
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
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 Center および File Exchange で Legend についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!