Code covered by the BSD License  

Highlights from
ZoomBox

image thumbnail
from ZoomBox by Doug Hull
Movable, stretchable zoom box in parent axes controls axes limits in all children axes.

refreshAxesAndZoomBoxFromAppData(hParentAxes, updateOnlyBox)
function refreshAxesAndZoomBoxFromAppData(hParentAxes, updateOnlyBox)
%refreshAxesAndZoomBoxFromAppData refreshes screen elements.
%
% Helper function for ZOOMBOX

if nargin < 2
    updateOnlyBox = 0;
end

hCorners = getappdata(hParentAxes, 'hZBcorners');

xValsCell = get(hCorners, 'Xdata');
yValsCell = get(hCorners, 'Ydata');

for i = 1: length(xValsCell)
    xVals(i) = xValsCell{i};
    yVals(i) = yValsCell{i};
end

xMin = min(xVals);
xMax = max(xVals);
yMin = min(yVals);
yMax = max(yVals);

if ~updateOnlyBox
    hChildAxis = getappdata(hParentAxes,'hZBchildAxes');
    set(hChildAxis, 'xlim', [xMin, xMax]);
    set(hChildAxis, 'ylim', [yMin, yMax]);
end

hZoomBox = getappdata(hParentAxes, 'hZBzoomBox');
set(hZoomBox, 'xData', [xMin, xMin, xMax, xMax]);
set(hZoomBox, 'yData', [yMin, yMax, yMax, yMin]);

drawnow
% Copyright 2007 - 2009 The MathWorks, Inc.

Contact us at files@mathworks.com