from
fix_x_limits
by Pekka Kumpulainen
Forces the same XLim to all axis
|
| fix_x_limits(h,lims)
|
function fix_x_limits(h,lims)
% fix_x_limits fixes all axis in current figure to the maximum span found
%
% fix_x_limits(h) fixes XLim property of all axis objects in h
% or all axes parented under h if figure handles
% to maximum span found within all axes
%
% fix_x_limits(h,limits) fixes all to given limits: [minx maxx]
% P.K. 13.2.2007
if nargin < 1
h = gcf;
end
ht = get(h,'Type');
if all(strcmp('axes',ht))
ha = h;
elseif all(strcmp('figure',ht))
ha = findobj(h,'type','axes');
end
if isa(ha,'cell')
ha = cell2mat(ha);
end
if nargin < 2
xlims = get(ha,'XLim');
if isa(xlims,'cell')
xlims = cell2mat(xlims);
end
lims = [min(xlims(:,1)) max(xlims(:,2))];
end
set(ha,'XLim',lims)
|
|
Contact us at files@mathworks.com