Legend is not showing all the colors - bar plot
Show older comments
Hi everyone!
My MATLAB code creates the bar plot you see below, however the legend outputs only two colors when in reality the bars are of 3 colors, how can I also get the legend for the blue color corresponding to 'Photos'. Thanks in advance, bye!
singleObjsPerc= rand(4,12);
TecniquesName = {'A', 'B', 'C', 'D', 'E', 'F'};
objName = {'Bottle', 'Sanitizer', 'Coffee cup', 'Notebook'};
for i = 1:4
subplot(2,2,i)
b=bar([singleObjsPerc(i,1:2); singleObjsPerc(i,3:4); singleObjsPerc(i,5:6); singleObjsPerc(i,7:8); singleObjsPerc(i,9:10); singleObjsPerc(i,11:12)],'FaceColor','flat');
aux=b(1,1);
aux.CData(1,:) = [0.9290, 0.6940, 0.1250];
title(objName{i});
set(gca,'XTickLabel',TecniquesName);
end
legend('Kinect','Photos', 'Video', 'Location', 'northwest')
Accepted Answer
More Answers (0)
Categories
Find more on Just for fun 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!

