How do I set "hold all" for an array of axes handles?
2 views (last 30 days)
Show older comments
Suppose I have a vector of axes handles, for instance:
ax = subplot(2,1,1);
% ...
ax(2) = subplot(2,1,2);
% ...
I would like to set "hold all" for all of them, something like:
for ii=1:length(ax),
hold(ax(ii), 'all');
end
It would be nicer to simply be able to do:
hold(ax, 'all');
where ax is a vector of axes handles. But this is specifically disallowed. In hold.m there is even the comment, "must not be a vector of handles" -- why is this?
I'm not sure whether this is a question or a feature request. (-:
0 Comments
Answers (2)
Jan
on 14 Jun 2011
If you look inside the source of HOLD, you see, that it is a wrapper for the command:
set(ax, 'NextPlot', 'add')
But exactly this command can be called als if ax is a vector.
HOLD('all') sets the NextPlot property of the figure also. This can be done manually also:
set(FigHandle, 'NextPlot', 'add');
3 Comments
Jan
on 15 Jun 2011
@Walter: You are right. But I cannot see any drawbacks in omitting the SETAPPDATA call inside a real world program. AFAICS, these application data "PlotHoldStyle" are used in \sparfun\gplot.m only, but I do have a limited number of toolboxes only.
Walter Roberson
on 15 Jun 2011
The documented behavior of hold all is,
===
hold all holds the plot and the current line color and line style so that subsequent plotting commands do not reset the ColorOrder and ColorOrder property values to the beginning of the list. Plotting commands continue cycling through the predefined colors and linestyles from where the last plot stopped in the list.
===
The major use of the color order would be in plot(), which is a built-in and so not searchable for particular text strings.
Walter Roberson
on 14 Jun 2011
The code simply isn't designed to loop around to process a vector of axes.
You can define:
holds = @(ax,varargin) arrayfun(@(oneax) hold(oneax,varargin{:}), ax);
and then holds(ax, 'all') would do the task.
0 Comments
See Also
Categories
Find more on Axes Appearance in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!