Why does the LEGEND function only display 20 strings in MATLAB 7.4 (R2007a)?

3 次查看(过去 30 天)
If I execute the following commands:
plot(rand(25))
legend('show')
only the 20 first text strings are displayed in the legend.

采纳的回答

MathWorks Support Team
This enhancement has been incorporated in Release 2008a (R2008a). Current versions of MATLAB now have a limit of 50 entries for legend. If you would like to add more entries than that, see the following MATLAB Answers post:
For previous product releases, read below for a possible workaround:
The maximum number of entries for a LEGEND is 20.
MATLAB is a viewable source language, meaning that you can access the source code and read and modify it. You can go into the code for LEGEND.M and change the number 20 on lines 628 and 630 to reflect whatever values you think are best.
if auto_children && length(ch) > 20,
% only automatically add first 20 to cut down on huge lists
ch = ch(1:20);
end
You change the MATLAB source code at your own risk and before editing the source code make a back-up of the file.
  2 个评论
Jan Kappen
Jan Kappen 2018-5-4
编辑:Jan Kappen 2018-5-4
Does not work in recent Matlab Versions (limit of 50). Please see https://de.mathworks.com/matlabcentral/answers/383371-how-to-make-all-the-legend-appear-in-a-plot. Any workaround?
nevermind, found it: https://de.mathworks.com/matlabcentral/answers/362378-why-does-my-legend-only-display-50-entries
Solution is to create multiple legends.
Mary Abbott
Mary Abbott 2018-5-9
Hi Jan,
Thanks for bringing this up. We've updated the answer to point to that solution for newer versions.

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Legend 的更多信息

产品


版本

R2007a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by