This is a static copy of a profile report

Home

newplot (Calls: 5, Time: 0.071 s)
Generated 18-May-2021 16:05:22 using performance time.
function in file /usr/local/MATLAB/R2021a/toolbox/matlab/graphics/axis/newplot.m
Copy to new window for comparing multiple runs

Parents (calling functions)

Function NameFunction TypeCalls
newplotwrapperfunction5
Lines where the most time was spent

Line NumberCodeCallsTotal Time% TimeTime Plot
93
ax = ObserveAxesNextPlot(ax, h...
50.037 s52.7%
77
ax = gca(fig);
50.026 s36.4%
47
fig = gobjects(0);
50.003 s3.9%
69
fig = ObserveFigureNextPlot(fi...
50.002 s2.4%
48
ax = gobjects(0);
50.001 s1.0%
All other lines  0.003 s3.6%
Totals  0.071 s100% 
Children (called functions)

Function NameFunction TypeCallsTotal Time% TimeTime Plot
newplot>ObserveAxesNextPlotsubfunction50.037 s52.3%
...asPlugin>CanvasPlugin.createCanvasclass method10.019 s26.6%
gobjectsfunction100.003 s3.8%
...(src,event)hObj.childAdded(src,event)anonymous function10.002 s2.7%
newplot>ObserveFigureNextPlotsubfunction50.001 s2.0%
...anager>ScribeStackManager.getLayerclass method10.000 s0.4%
...ner.CartesianAxesInteractionContainerclass method10.000 s0.2%
...vasPlugin>CanvasPlugin.getInstanceclass method10.000 s0.1%
Self time (built-ins, overhead, etc.)  0.008 s11.9%
Totals  0.071 s100% 
Code Analyzer results
No Code Analyzer messages.
Coverage results
Show coverage for parent directory
Total lines in function98
Non-code lines (comments, blank lines)51
Code lines (lines that can run)47
Code lines that did run26
Code lines that did not run21
Coverage (did run/can run)55.32 %
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-2020 The MathWorks, Inc.
  35 
%   Built-in function.
  36 

< 0.001 
      5 
  37
if nargin == 0 || isempty(hsave) 
< 0.001 
      5 
  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);
< 0.001 
      5 
  44
end 
  45 

  46 
% Get the ancestor axes and figure from the input (if present).
  0.003 
      5 
  47
fig = gobjects(0); 
< 0.001 
      5 
  48
ax = gobjects(0); 
< 0.001 
      5 
  49
if ~isempty(hsave) 
  50 
    obj = hsave;
  51 
    while ~isempty(obj)
  52 
        if isgraphics(obj, 'figure')
  53 
            fig = obj;
  54 
        elseif isgraphics(obj,'axes') || isgraphics(obj,'polaraxes') || isgraphics(obj,'geoaxes')
  55 
            ax = obj;
  56 
        end
  57 
        obj = obj.Parent;
  58 
    end
< 0.001 
      5 
  59
end 
  60 

  61 
% If no axes or figure was found, create a new figure. Check if the axes is
  62 
% empty to avoid creating a figure if an unparented axes was provided.
< 0.001 
      5 
  63
if isempty(fig) && isempty(ax) 
< 0.001 
      5 
  64
    fig = gcf; 
< 0.001 
      5 
  65
end 
  66 

< 0.001 
      5 
  67
if ~isempty(fig) 
  68 
    % Prepare the figure based on the NextPlot property.
  0.002 
      5 
  69
    fig = ObserveFigureNextPlot(fig, hsave); 
  70 

  71 
    % Set figure's NextPlot property to 'add' after obeying the previous setting.
< 0.001 
      5 
  72
    fig.NextPlot = 'add'; 
< 0.001 
      5 
  73
end 
  74 

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

< 0.001 
      5 
  92
if checkNextPlot 
  0.037 
      5 
  93
    ax = ObserveAxesNextPlot(ax, hsave); 
< 0.001 
      5 
  94
end 
  95 

< 0.001 
      5 
  96
if nargout 
< 0.001 
      5 
  97
    axReturn = ax; 
< 0.001 
      5 
  98
end 

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