This is a static copy of a profile report

Home

Function details for newplotThis is a static copy of a profile report

Home

newplot (Calls: 2, Time: 0.041 s)
Generated 01-May-2020 20:23:08 using performance time.
function in file /Applications/MATLAB_R2018a.app/toolbox/matlab/graphics/newplot.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
imagescfunction2
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
73
ax = gca(fig);
20.018 s44.1%
89
ax = ObserveAxesNextPlot(ax, h...
20.014 s34.4%
47
fig = gobjects(0);
20.005 s13.1%
66
fig = ObserveFigureNextPlot(fi...
20.001 s2.8%
48
ax = gobjects(0);
20.001 s1.6%
All other lines  0.002 s4.1%
Totals  0.041 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
newplot>ObserveAxesNextPlotsubfunction20.014 s33.7%
...asPlugin>CanvasPlugin.createCanvasclass method20.008 s19.4%
gobjectsfunction40.005 s12.4%
...vasPlugin>CanvasPlugin.getInstanceclass method20.001 s2.9%
newplot>ObserveFigureNextPlotsubfunction20.001 s2.2%
Self time (built-ins, overhead, etc.)  0.012 s29.5%
Totals  0.041 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function94
Non-code lines (comments, blank lines)49
Code lines (lines that can run)45
Code lines that did run20
Code lines that did not run25
Coverage (did run/can run)44.44 %
Function listing
time 
Calls 
 line
   1 
function axReturn = newplot(hsave)
   2 
%NEWPLOT Prepares figure, axes for graphics according to NextPlot.
   3 
%   H = NEWPLOT returns the handle of the prepared axes.
   4 
%   H = NEWPLOT(HSAVE) prepares and returns an axes, but does not
   5 
%   delete any objects whose handles appear in HSAVE. If HSAVE is
   6 
%   specified, the figure and axes containing HSAVE are prepared
   7 
%   instead of the current axes of the current figure. If HSAVE is
   8 
%   empty, NEWPLOT behaves as if it were called without any inputs.
   9 
%
  10 
%   NEWPLOT is a standard preamble command that is put at
  11 
%   the beginning of graphics functions that draw graphs
  12 
%   using only low-level object creation commands. NEWPLOT
  13 
%   "does the right thing" in terms of determining which axes and/or
  14 
%   figure to draw the plot in, based upon the setting of the
  15 
%   NextPlot property of axes and figure objects, and returns a
  16 
%   handle to the appropriate axes.
  17 
%
  18 
%   The "right thing" is:
  19 
%
  20 
%   First, prepare a figure for graphics:
  21 
%   Clear and reset the current figure using CLF RESET if its NextPlot
  22 
%   is 'replace', or clear the current figure using CLF if its
  23 
%   NextPlot is 'replacechildren', or reuse the current figure as-is
  24 
%   if its NextPlot is 'add', or if no figures exist, create a figure.
  25 
%   When the figure is prepared, set its NextPlot to 'add', and then
  26 
%   prepare an axes in that figure:
  27 
%   Clear and reset the current axes using CLA RESET if its NextPlot
  28 
%   is 'replace', or clear the current axes using CLA if its NextPlot
  29 
%   is 'replacechildren', or reuse the current axes as-is if its
  30 
%   NextPlot is 'add', or if no axes exist, create an axes.
  31 
%
  32 
%   See also HOLD, ISHOLD, FIGURE, AXES, CLA, CLF.
  33 

  34 
%   Copyright 1984-2017 The MathWorks, Inc.
  35 
%   Built-in function.
  36 

< 0.001 
      2 
  37
if nargin == 0 || isempty(hsave) 
< 0.001 
      2 
  38
    hsave = []; 
  39 
elseif ~isscalar(hsave) || ~ishghandle(hsave)
  40 
    error(message('MATLAB:newplot:InvalidHandle'))
  41 
else
  42 
    % Make sure we have an object handle.
  43 
    hsave = handle(hsave);
  44 
end
  45 

  46 

  0.005 
      2 
  47
fig = gobjects(0); 
< 0.001 
      2 
  48
ax = gobjects(0); 
  49 

< 0.001 
      2 
  50
if ~isempty(hsave) 
  51 
    obj = hsave;
  52 
    while ~isempty(obj)
  53 
        if isgraphics(obj, 'figure')
  54 
            fig = obj;
  55 
        elseif isgraphics(obj, 'axes') || isgraphics(obj,'polaraxes')
  56 
            ax = obj;
  57 
        end
  58 
        obj = obj.Parent;
  59 
    end
  60 
end
  61 

< 0.001 
      2 
  62
if isempty(fig) 
< 0.001 
      2 
  63
    fig = gcf; 
< 0.001 
      2 
  64
end 
  65 

  0.001 
      2 
  66
fig = ObserveFigureNextPlot(fig, hsave); 
  67 

  68 
% Set figure's NextPlot property to 'add' after obeying the previous setting.
< 0.001 
      2 
  69
fig.NextPlot = 'add'; 
  70 

< 0.001 
      2 
  71
checkNextPlot = true; 
< 0.001 
      2 
  72
if isempty(ax) 
  0.018 
      2 
  73
    ax = gca(fig); 
< 0.001 
      2 
  74
    if ~isa(ax,'matlab.graphics.axis.Axes') 
  75 
        if isprop(ax,'NextPlot') && ishold(ax)
  76 
            error(message('MATLAB:newplot:HoldOnMixing'))
  77 
        else
  78 
            ax = matlab.graphics.internal.swapaxes(ax,@axes);
  79 
            
  80 
            % We just creaetd a new axes, no need to check NextPlot
  81 
            checkNextPlot = false;
  82 
        end
  83 
    end
  84 
elseif ~any(ishghandle(ax))
  85 
    error(message('MATLAB:newplot:NoAxesParent'))
  86 
end
  87 

< 0.001 
      2 
  88
if checkNextPlot 
  0.014 
      2 
  89
    ax = ObserveAxesNextPlot(ax, hsave); 
< 0.001 
      2 
  90
end 
  91 

< 0.001 
      2 
  92
if nargout 
< 0.001 
      2 
  93
    axReturn = ax; 
< 0.001 
      2 
  94
end 

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