フィルターのクリア

How do you get a legend to have different marker sizes?

8 ビュー (過去 30 日間)
Kulan Sinclair
Kulan Sinclair 2018 年 7 月 4 日
回答済み: Walter Roberson 2018 年 7 月 4 日
I have a set of dummy points and I am trying to make a legend with most of the markers being the same size but 3 of them being different sizes(can be based on the size of the points in the scatter plot or resized individually) list1-5 should have the same marker size and Phase A should have a larger marker size Phase B should have the normal marker size and Phase C should have a small marker size. The text should remain the same in all cases.
figure
hold on
%sets up data for the legend
list1 = scatter(NaN,NaN, 40, 'r', 'filled');
list1.MarkerEdgeColor = 'k';
list2 = scatter(NaN,NaN, 40, 'y', 'filled');
list2.MarkerEdgeColor = 'k';
list3 = scatter(NaN,NaN, 40, 'g', 'filled');
list3.MarkerEdgeColor = 'k';
list4 = scatter(NaN,NaN, 40, 'c', 'filled');
list4.MarkerEdgeColor = 'k';
list5 = scatter(NaN,NaN, 40, 'm', 'filled');
list5.MarkerEdgeColor = 'k';
list6 = scatter(NaN,NaN, 90, 'w', 'filled');
list6.MarkerEdgeColor = 'k';
list7 = scatter(NaN,NaN, 40, 'w', 'filled');
list7.MarkerEdgeColor = 'k';
list8 = scatter(NaN,NaN, 10, 'w', 'filled');
list8.MarkerEdgeColor = 'k';
lgd = legend([list1 list2 list3 list4 list5 list6 list7 list8], 'list1',...
'list2', 'list3', 'list4', 'list5', 'Phase A',...
'Phase B', 'Phase C','AutoUpdate ','Off', 'Location', 'northwest');

採用された回答

Walter Roberson
Walter Roberson 2018 年 7 月 4 日
Since those are all dummy scatter() calls to create the legend entries, replace them with calls to plot(), such as
list1 = plot(nan, nan, 'MarkerSize', 40, 'MarkerEdgeColor', 'k', 'MarkerFaceColor', 'r');

その他の回答 (0 件)

カテゴリ

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

製品


リリース

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by