legend entry for geometric object in matlab plot

15 ビュー (過去 30 日間)
Optical_Stress
Optical_Stress 2018 年 3 月 18 日
コメント済み: Rik 2018 年 3 月 26 日
I have used the rectangle function to generate a geometric object with a specified fill color using rgb [ x y z].
How can I generate a legend entry for my object?
I have thought of generating a random point of the same color within the boundaries of my object, but wanted to know if there was a more obvious solution?

回答 (1 件)

Rik
Rik 2018 年 3 月 18 日
You can use the handle to the patch object that fill returns.
h=fill([1 1 0 0],[0 1 1 0],'r');
axis([-0.5 1.5 -0.5 1.5])
legend(h,'red square')
  1 件のコメント
Rik
Rik 2018 年 3 月 26 日
If you found this answer useful, please mark it as accepted answer. It will make it easier for other people with the same question to find an answer, as well as give me reputation points. If this didn't solve your question, please comment with what problems you are still having.

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeLegend についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by