Creating a Legend for Two Bar Plots (Plotted Together on Same Figure)
이전 댓글 표시
Hi, I am having trouble getting a legend that incorporates both bar graphs (one white & one black) that are plotted together on the same figure using 'hold on'. Each bar also has an error bar. An example of my code is:
figure;
errorbar(x, meanValue, lowerError, upperError, 'k', 'LineStyle', 'none');
hold on;
bar(x, meanValue, 'w');
errorbar(x, -meanValue2, -upperError2, -lowerError, 'k', 'LineStyle', 'none');
bar(x, -meanValue2, 'k');
legend('Label1','Label2');
When I do this, the legend has no color for Label1 (black), but has a color for Label2 (white). How can I get the black color to show up in the legend for Label1. Any help would be greatly appreciated. Thank you.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Legend에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!