How do I add a legend to a boxplot in MATLAB?
Show older comments
I created a boxplot and would like to add a legend to it, but when I call legend I get the following warning message and there is no legend in the plot figure:
Warning: Plot empty.
> In legend at 286
Is it possible to add a legend to a box plot? My code is:
figure;
colors = [1 0 0; 1 0 0; 0 0 1; 0 0.5 0; 0 0.5 0; 0 0.5 0];
x = boxplot(rand(100,6),'Colors',colors);
legend('Group A','Group B','Group C')
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!