フィルターのクリア

plot legends with custom symbols

48 ビュー (過去 30 日間)
Chris
Chris 2015 年 4 月 6 日
編集済み: Chris 2015 年 4 月 6 日
I am doing something like
>> XX = 0; YY = 0;
>> h1 = plot( XX, YY, ['.y'] ); hold on
>> set(h1, 'markersize', 30);
>> h2 = plot( XX, YY, ['.r'] );
This gives a very nice red dot on yellow background that I want to use as a special symbol, but is there a way to make these red on yellow dots appear as such in the legend box? Can you 'merge' handles, I know you can do >> legend([h1,h2],'foo','foo2'); but that gives two legend entries where I want the red/yellow dot treated as a combine unit as you see them in the plot.

採用された回答

Kelly Kearney
Kelly Kearney 2015 年 4 月 6 日
It might be easier to just play around with marker size/line width combos to get the same effect without duplicating the plotted data:
h = plot(0,0, ...
'marker', 'o', ...
'markerfacecolor', 'r', ...
'markeredgecolor', 'y', ...
'linewidth', 2);
legend(h);
  1 件のコメント
Chris
Chris 2015 年 4 月 6 日
編集済み: Chris 2015 年 4 月 6 日
Very good alternative, thanks!
hh = plot(0,0,'oy'); set(hh, 'MarkerFaceColor','r'); set(hh, 'markersize', 7.5); set(hh, 'linewidth', 3); legend(hh, 'foo');
looks real good to me.

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

その他の回答 (0 件)

カテゴリ

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