Eliminate Duplicates in a Legend
Show older comments
Hello!
I am trying to plot 27 points that fit into 12 categories and then have a legend showing what symbols are used for each of the categories. I'm probably overcomplicating this whole thing, but here is the code (abbreviated)
figure
for n = 1:num_stopes % There are 27 of them
ppv = PPV(n); % Vibration Level
this_month = month(n); % Month Number
recep = str2double(regexprep(receptor_list{n},'R','')); % Get Receptor Number. receptor_list is cell array
switch recep % There are 12 receptors
case recep_nums(1)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','r','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(2)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','g','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(3)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','b','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(4)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','m','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(5)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','c','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(6)
plot(this_month,ppv,'Marker','o','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','y','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(7)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','r','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(8)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','g','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(9)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','b','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(10)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','m','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(11)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','c','DisplayName',['Receptor ',num2str(recep)]);
case recep_nums(12)
plot(this_month,ppv,'Marker','diamond','LineStyle','none','MarkerEdgeColor','k','MarkerFaceColor','y','DisplayName',['Receptor ',num2str(recep)]);
end
hold on
end
legend('show');
ylim([0 2.5]);
ylabel('PPV (in/s)')
xlabel('Month')
title('PPV for Receptors Close to Early Stopes')
Here is the resultant figure and legend:

Thank you for any help!
Doug Anderson
Accepted Answer
More Answers (0)
Categories
Find more on Legend in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!