legend causes thousands of function calls
1 次查看(过去 30 天)
显示 更早的评论
I have a simple matlab script wich loads a log file (MAT-file) of roughly 270Mb and then plots the data in some plots. It takes a while to process the data but after roughly 2min its done. However, if I want to add a legend to the plots the script takes over 90min to execute. Using 'profile' I see that the script causes over 1 million function calls to
scribe/private/get_legendable_children
scribe/private/islegendable
ismethod
cell.strmatch
strmacht
Does anybody know this problem? I don't do any fancy stuff. I only load and plot a Mat file.
Thank you for any ideas!
0 个评论
采纳的回答
Walter Roberson
2013-10-18
How are you calling legend? Are you just passing in the legend strings? If so then MATLAB needs to visit every object (such as lines) that are legend'able in order to determine whether they have custom legends, need to have a legend entry, or so on.
If that is what you are doing, then when you call legend(), pass in the explicit list of object handles that you are generating legends for, so that it does not need to visit the other objects.
2 个评论
Jos (10584)
2013-10-19
Using
legend(handles, CellArrayofStrings)
might be faster than
legend(handles, String1, String2, ...)
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Legend 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!