Why does my legend only display 50 entries?
Show older comments
I have a plot with more than 50 items and I would like to add a legend for all of them. The legend gets truncated at 50.
p = plot(magic(100));
labels = cellstr(num2str((1:100)'));
legend(p,labels)
Accepted Answer
More Answers (1)
Eric Sargent
on 9 Dec 2020
Legend will cap the number of entries at 50 if no handles are specified. To have all objects in an axes show up, pass in their handles to the legend command.
p = plot(magic(100));
legend(p);
1 Comment
Walter Roberson
on 24 Dec 2020
It gets the axes handles from ancestor(p, 'axes') so it does not need to be passed a handle axes.
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!