How do I set "hold all" for an array of axes handles?

4 ビュー (過去 30 日間)
Tobin Fricke
Tobin Fricke 2011 年 6 月 14 日
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. (-:

回答 (2 件)

Jan
Jan 2011 年 6 月 14 日
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 件のコメント
Jan
Jan 2011 年 6 月 15 日
@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
Walter Roberson 2011 年 6 月 15 日
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
Walter Roberson 2011 年 6 月 14 日
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.

カテゴリ

Help Center および File ExchangeLine Plots についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by