필터 지우기
필터 지우기

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 CenterFile Exchange에서 Legend에 대해 자세히 알아보기

제품


릴리스

R2017a

Community Treasure Hunt

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

Start Hunting!

Translated by