time | calls | line |
---|
| | 107 | function ax = ObserveAxesNextPlot(ax, hsave)
|
| | 108 | %
|
| | 109 | % Helper fcn for preparing axes for nextplot, optionally
|
| | 110 | % preserving specific existing descendants
|
| | 111 | % GUARANTEED to return an axes in the same figure as the passed-in
|
| | 112 | % axes, even if that axes gets deleted by an overzealous create or
|
| | 113 | % delete fcn anywhere in the figure.
|
| | 114 | %
|
| | 115 |
|
| | 116 | % for performance only call ancestor when needed
|
0.48 | 6629 | 117 | fig = get(ax,'Parent');
|
0.20 | 6629 | 118 | if ~strcmp(get(fig,'Type'),'figure')
|
| | 119 | fig = ancestor(fig,'figure');
|
| | 120 | end
|
| | 121 |
|
0.17 | 6629 | 122 | switch get(ax,'nextplot')
|
0.01 | 6629 | 123 | case 'replace'
|
| | 124 | cla(ax, 'reset',hsave);
|
| 6629 | 125 | case 'replacechildren'
|
| | 126 | cla(ax, hsave);
|
0.03 | 6629 | 127 | case {'add','new'}
|
| | 128 | % nothing
|
| 6629 | 129 | end
|
| | 130 |
|
0.08 | 6629 | 131 | if ~any(ishghandle(ax)) && isempty(hsave)
|
| | 132 | if ~any(ishghandle(fig))
|
| | 133 | ax = axes;
|
| | 134 | else
|
| | 135 | ax = axes('parent',fig);
|
| | 136 | end
|
| | 137 | end
|