1 | function axesZoom(obj, evd, tag, factor) |
---|
2 | % Zoom in axes |
---|
3 | % |
---|
4 | % AXESZOOM(OBJ, EVD, TAG, FACTOR) |
---|
5 | % Zoom in axes designed by TAG. If FACTOR is given, it is applied to |
---|
6 | % correct the coordinates. The center is the position of the mouse when |
---|
7 | % called.If not, coordinates are supposed to be present in the UserData |
---|
8 | % part, in a struct coords.xlim |
---|
9 | % .ylim |
---|
10 | % |
---|
11 | % Typical use is associated with a context menu. The outlier module |
---|
12 | % provides a good example. |
---|
13 | % |
---|
14 | % This is part of a generic tool for zooming in plots. |
---|
15 | % See axesZoomRect.m |
---|
16 | % |
---|
17 | % obj: hObject [object] |
---|
18 | % evd: event data [string] |
---|
19 | % tag: tag of the concenred axes [string] |
---|
20 | % factor: zoom factor applied [double] |
---|
21 | |
---|
22 | % Copyright 2006-2007 INRIA |
---|
23 | % |
---|
24 | % This file is part of WellReader |
---|
25 | % |
---|
26 | % WellReader is free software: you can redistribute it and/or modify |
---|
27 | % it under the terms of the GNU Lesser General Public License as published by |
---|
28 | % the Free Software Foundation, either version 3 of the License, or |
---|
29 | % (at your option) any later version. |
---|
30 | % |
---|
31 | % WellReader is distributed in the hope that it will be useful, |
---|
32 | % but WITHOUT ANY WARRANTY; without even the implied warranty of |
---|
33 | % MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
---|
34 | % GNU Lesser General Public License for more details. |
---|
35 | % |
---|
36 | % You should have received a copy of the GNU Lesser General Public License |
---|
37 | % along with WellReader. If not, see <http: |
---|
38 | |
---|
39 | ax = findobj('Tag', tag); |
---|
40 | if nargin == 4 % factor given |
---|
41 | xlim = get(ax, 'XLim'); |
---|
42 | ylim = get(ax, 'YLim'); |
---|
43 | center = get(ax, 'CurrentPoint'); |
---|
44 | xcenter = center(1,1); |
---|
45 | ycenter = center(1,2); |
---|
46 | xwidth = (xlim(2) - xlim(1)) / (2 * factor); |
---|
47 | set(ax, 'XLim', [xcenter-xwidth, xcenter+xwidth]); |
---|
48 | ywidth = (ylim(2) - ylim(1)) / (2 * factor); |
---|
49 | set(ax, 'YLim', [ycenter-ywidth, ycenter+ywidth]); |
---|
50 | else |
---|
51 | coords = get(ax, 'UserData'); |
---|
52 | set(ax, 'XLim', coords.xlim); |
---|
53 | set(ax, 'YLim', coords.ylim); |
---|
54 | end |
---|
55 | |
---|
56 | end |
---|