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-2010 The MathWorks, Inc.
|
| | 35 | % Built-in function.
|
| | 36 |
|
| 6629 | 37 | if nargin == 0 || isempty(hsave)
|
0.03 | 6629 | 38 | hsave = [];
|
| | 39 | elseif ~isscalar(hsave) || ~ishghandle(hsave)
|
| | 40 | error(message('MATLAB:newplot:InvalidHandle'))
|
| | 41 | end
|
| | 42 |
|
| | 43 |
|
0.01 | 6629 | 44 | fig = [];
|
| 6629 | 45 | ax = [];
|
| | 46 |
|
0.03 | 6629 | 47 | if ~isempty(hsave)
|
| | 48 | obj = hsave;
|
| | 49 | while ~isempty(obj)
|
| | 50 | if strcmp(get(obj,'type'),'figure')
|
| | 51 | fig = obj;
|
| | 52 | elseif strcmp(get(obj,'type'),'axes')
|
| | 53 | ax = obj;
|
| | 54 | end
|
| | 55 | obj = get(obj,'parent');
|
| | 56 | end
|
| | 57 | end
|
| | 58 |
|
| 6629 | 59 | if isempty(fig)
|
0.11 | 6629 | 60 | fig = gcf;
|
0.01 | 6629 | 61 | end
|
| | 62 |
|
0.59 | 6629 | 63 | fig = ObserveFigureNextPlot(fig, hsave);
|
| | 64 | % for clay
|
0.37 | 6629 | 65 | set(fig,'nextplot','add');
|
| | 66 |
|
0.01 | 6629 | 67 | if isempty(ax)
|
0.14 | 6629 | 68 | ax = gca(fig);
|
| | 69 | elseif ~any(ishghandle(ax))
|
| | 70 | error(message('MATLAB:newplot:NoAxesParent'))
|
| | 71 | end
|
| | 72 |
|
1.13 | 6629 | 73 | ax = ObserveAxesNextPlot(ax, hsave);
|
| | 74 |
|
0.02 | 6629 | 75 | if nargout
|
0.02 | 6629 | 76 | axReturn = ax;
|
0.02 | 6629 | 77 | end
|
Other subfunctions in this file are not included in this listing.