This is a static copy of a profile report

Home

legend>make_legend (Calls: 8, Time: 0.756 s)
Generated 16-Jul-2020 17:08:57 using performance time.
subfunction in file /Applications/MATLAB_R2020a.app/toolbox/matlab/scribe/legend.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
legendfunction8
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
315
leg = matlab.graphics.illustra...
80.254 s33.5%
334
[propargs, ch, strings] = proc...
80.234 s30.9%
360
leg.Axes = ha;
80.205 s27.1%
383
set(leg,propargs{:});
80.016 s2.1%
321
leg.LimitMaxLegendEntries = fa...
80.009 s1.2%
All other lines  0.039 s5.1%
Totals  0.756 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
Legend.Legend>Legend.Legendclass method80.251 s33.2%
legend>process_inputssubfunction80.233 s30.8%
Legend.Legend>Legend.set.Axesclass method80.203 s26.9%
Legend.Legend>Legend.set.Locationclass method80.015 s1.9%
legend>setDisplayNamessubfunction80.008 s1.0%
...d>Legend.set.LimitMaxLegendEntriesclass method80.006 s0.8%
legend>find_legendsubfunction80.006 s0.7%
Legend.Legend>Legend.set.EdgeColor_Iclass method80.003 s0.5%
Legend.doPostSetupfunction80.003 s0.4%
legend>lcl_is2Dsubfunction80.002 s0.2%
Legend.Legend>Legend.getGraphicsAxesclass method80.001 s0.1%
Legend.Legend>Legend.get.TextColor_Iclass method80.000 s0.1%
isplotyyaxesfunction80.000 s0.0%
Legend.Legend>Legend.get.Color_Iclass method80.000 s0.0%
Legend.Legend>Legend.get.EdgeColor_Iclass method80.000 s0.0%
Self time (built-ins, overhead, etc.)  0.025 s3.3%
Totals  0.756 s100% 
Code Analyzer results
Line numberMessage
302The value assigned to variable 'ch' might be unused.
303The value assigned to variable 'strings' might be unused.
334A Code Analyzer message was once suppressed here, but the message is no longer generated.
Coverage results
Show coverage for parent directory
Total lines in function90
Non-code lines (comments, blank lines)29
Code lines (lines that can run)61
Code lines that did run42
Code lines that did not run19
Coverage (did run/can run)68.85 %
Function listing
time 
Calls 
 line
 299 
function make_legend(ha,argin,version_flag,clamp)
 300 

  0.006 
      8 
 301
leg = find_legend(ha); 
< 0.001 
      8 
 302
ch = []; 
< 0.001 
      8 
 303
strings = {}; 
 304 

 305 
% Always create a new legend if the user has requested a compatible legned
 306 
% or if the existing legend is a compatible legend
< 0.001 
      8 
 307
if strcmp(version_flag,'on') || strcmp(get(leg,'version'),'on') 
 308 
    delete(leg)
 309 
    leg = [];
< 0.001 
      8 
 310
end 
 311 

< 0.001 
      8 
 312
new_legend = false; 
< 0.001 
      8 
 313
if isempty(leg) 
< 0.001 
      8 
 314
    new_legend = true; 
  0.254 
      8 
 315
    leg = matlab.graphics.illustration.Legend; 
  0.003 
      8 
 316
    leg.doPostSetup(version_flag); 
< 0.001 
      8 
 317
    leg.Visible = 'off'; 
< 0.001 
      8 
 318
    if(clamp) 
 319 
        leg.LimitMaxLegendEntries = true;
< 0.001 
      8 
 320
    else  
  0.009 
      8 
 321
        leg.LimitMaxLegendEntries = false; 
< 0.001 
      8 
 322
    end 
 323 
else
 324 
    % For existing legends, make sure the ALM is dirty as a result of this
 325 
    % legend call.  We don't need to do this if the legend is in a layout
 326 
    if ~isa(leg.Parent, 'matlab.graphics.layout.Layout')
 327 
        hManager  = matlab.graphics.shape.internal.AxesLayoutManager.getManager(leg.Axes);
 328 
        doMarkDirty(hManager);
 329 
    end
< 0.001 
      8 
 330
end 
 331 

< 0.001 
      8 
 332
try 
 333 
    % process input args
  0.234 
      8 
 334
    [propargs, ch, strings] = process_inputs(leg,ha,argin, new_legend); %#ok 
 335 
catch ME
 336 
    throwAsCaller(ME);
< 0.001 
      8 
 337
end 
 338 

< 0.001 
      8 
 339
if new_legend 
< 0.001 
      8 
 340
    try 
< 0.001 
      8 
 341
        fig = ancestor(ha,'figure'); 
< 0.001 
      8 
 342
        parent = get(ha,'Parent'); 
 343 

< 0.001 
      8 
 344
        if strcmp(get(ha,'color'),'none') 
 345 
            leg.Color_I = get(fig,'Color');
< 0.001 
      8 
 346
        else 
  0.001 
      8 
 347
            leg.Color_I = get(ha,'Color'); 
< 0.001 
      8 
 348
        end 
  0.003 
      8 
 349
        leg.TextColor_I = get(parent,'DefaultTextColor'); 
  0.006 
      8 
 350
        leg.EdgeColor_I = get(parent,'DefaultAxesXColor'); 
 351 

 352 
        % apply 3D default
  0.003 
      8 
 353
        if ~lcl_is2D(getGraphicsAxes(leg,ha)) 
 354 
            leg.Location = 'northeastoutside';
< 0.001 
      8 
 355
        elseif isa(ha, 'matlab.graphics.axis.PolarAxes') 
 356 
            leg.Location = 'eastoutside';
< 0.001 
      8 
 357
        end 
 358 
        
 359 
        % set the peer axes
  0.205 
      8 
 360
        leg.Axes = ha; 
 361 
        
 362 
        % disable AutoUpdate for plotyy
< 0.001 
      8 
 363
        if matlab.graphics.illustration.internal.isplotyyaxes(ha) 
 364 
            % Make sure the discovered plotyy children don't get
 365 
            % overwritten by the autoUpdateCallback during the update
 366 
            % triggered by setting AutoUpdate to 'off';
 367 
            % The callback can only see children of the primary axes.
 368 
            leg.PlotChildrenSpecified = leg.PlotChildren_I;
 369 
            leg.AutoUpdate = 'off';
< 0.001 
      8 
 370
        end 
 371 
    catch
 372 
        leg.Axes = [];
 373 
        delete(leg);
 374 
        return
< 0.001 
      8 
 375
    end 
< 0.001 
      8 
 376
end 
 377 

 378 
% set DisplayNames
  0.008 
      8 
 379
setDisplayNames(ch,strings); 
 380 

 381 
% set user-specified PV pairs
< 0.001 
      8 
 382
if ~isempty(propargs) 
  0.016 
      8 
 383
    set(leg,propargs{:}); 
< 0.001 
      8 
 384
end 
 385 

 386 
% always make legend visible
 387 
% the purpose of make_legend is to put a legend on the figure
  0.001 
      8 
 388
set(leg,'Visible','on'); 

Other subfunctions in this file are not included in this listing.