How do you get a legend to have different marker sizes?
8 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
Kulan Sinclair
le 4 Juil 2018
Réponse apportée : Walter Roberson
le 4 Juil 2018
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');
0 commentaires
Réponse acceptée
Walter Roberson
le 4 Juil 2018
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 commentaires
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Legend dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!