time | calls | line |
---|
| | 1 | function hold(varargin)
|
| | 2 | %HOLD Hold current graph
|
| | 3 | % HOLD ON holds the current plot and all axis properties, including
|
| | 4 | % the current color and linestyle, so that subsequent graphing commands
|
| | 5 | % add to the existing graph without resetting the color and linestyle.
|
| | 6 | % HOLD OFF returns to the default mode whereby PLOT commands erase
|
| | 7 | % the previous plots and reset all axis properties before drawing
|
| | 8 | % new plots.
|
| | 9 | % HOLD, by itself, toggles the hold state.
|
| | 10 | % HOLD does not affect axis autoranging properties.
|
| | 11 | %
|
| | 12 | % HOLD ALL holds the plot and the current color and linestyle so
|
| | 13 | % that subsequent plotting commands will not reset the color and
|
| | 14 | % linestyle.
|
| | 15 | %
|
| | 16 | % HOLD(AX,...) applies the command to the Axes object AX.
|
| | 17 | %
|
| | 18 | % Algorithm note:
|
| | 19 | % HOLD ON sets the NextPlot property of the current figure and
|
| | 20 | % axes to "add".
|
| | 21 | % HOLD OFF sets the NextPlot property of the current axes to
|
| | 22 | % "replace".
|
| | 23 | %
|
| | 24 | % See also ISHOLD, NEWPLOT, FIGURE, AXES.
|
| | 25 |
|
| | 26 | % Copyright 1984-2008 The MathWorks, Inc.
|
| | 27 |
|
| | 28 | % Parse possible Axes input
|
| 96 | 29 | narginchk(0,2);
|
| | 30 |
|
| | 31 | % look for leading axes (must not be a vector of handles)
|
0.02 | 96 | 32 | [ax,args,nargs] = axescheck(varargin{:});
|
| | 33 |
|
| 96 | 34 | if isempty(ax)
|
| 96 | 35 | ax = gca;
|
| 96 | 36 | end
|
0.02 | 96 | 37 | fig = get(ax,'Parent');
|
| 96 | 38 | if ~strcmp(get(fig,'Type'),'figure')
|
| | 39 | fig = ancestor(fig,'figure');
|
| | 40 | end
|
| | 41 |
|
| 96 | 42 | if ~isempty(args)
|
| 96 | 43 | opt_hold_state = args{1};
|
| 96 | 44 | end
|
| | 45 |
|
| 96 | 46 | nexta = get(ax,'NextPlot');
|
| 96 | 47 | nextf = get(fig,'NextPlot');
|
| 96 | 48 | hold_state = strcmp(nexta,'add') && strcmp(nextf,'add');
|
| | 49 |
|
0.01 | 96 | 50 | if graphicsversion(ax,'handlegraphics')
|
| | 51 | if(nargs == 0)
|
| | 52 | if(hold_state)
|
| | 53 | set(ax,'NextPlot','replace');
|
| | 54 | disp(getString(message('MATLAB:hold:CurrentPlotReleased')));
|
| | 55 | else
|
| | 56 | set(fig,'NextPlot','add');
|
| | 57 | set(ax,'NextPlot', 'add');
|
| | 58 | disp(getString(message('MATLAB:hold:CurrentPlotHeld')));
|
| | 59 | end
|
| | 60 | setappdata(ax,'PlotHoldStyle',false);
|
| | 61 | elseif(strcmp(opt_hold_state, 'on'))
|
| | 62 | set(fig,'NextPlot','add');
|
| | 63 | set(ax,'NextPlot','add');
|
| | 64 | setappdata(ax,'PlotHoldStyle',false);
|
| | 65 | elseif(strcmp(opt_hold_state, 'off'))
|
| | 66 | set(ax,'NextPlot', 'replace');
|
| | 67 | setappdata(ax,'PlotHoldStyle',false);
|
| | 68 | elseif(strcmp(opt_hold_state, 'all'))
|
| | 69 | set(fig,'NextPlot','add');
|
| | 70 | set(ax,'NextPlot','add');
|
| | 71 | setappdata(ax,'PlotHoldStyle',true);
|
| | 72 | else
|
| | 73 | error(message('MATLAB:hold:UnknownOption'));
|
| | 74 | end
|
| 96 | 75 | else
|
| 96 | 76 | if(nargs == 0)
|
| | 77 | if(hold_state)
|
| | 78 | set(ax,'NextPlot','replace');
|
| | 79 | disp(getString(message('MATLAB:hold:CurrentPlotReleased')));
|
| | 80 | else
|
| | 81 | set(fig,'NextPlot','add');
|
| | 82 | set(ax,'NextPlot', 'add');
|
| | 83 | disp(getString(message('MATLAB:hold:CurrentPlotHeld')));
|
| | 84 | end
|
| 96 | 85 | elseif(strcmp(opt_hold_state, 'on'))
|
0.01 | 60 | 86 | set(fig,'NextPlot','add');
|
| 60 | 87 | set(ax,'NextPlot','add');
|
| 36 | 88 | elseif(strcmp(opt_hold_state, 'off'))
|
| 36 | 89 | set(ax,'NextPlot', 'replace');
|
| | 90 | elseif(strcmp(opt_hold_state, 'all'))
|
| | 91 | set(fig,'NextPlot','add');
|
| | 92 | set(ax,'NextPlot','add');
|
| | 93 | else
|
| | 94 | error(message('MATLAB:hold:UnknownOption'));
|
| | 95 | end
|
| 96 | 96 | end
|