akZoom

版本 1.10.1.0 (12.9 KB) 作者: Alexander Kessel
Zooming and panning with the mouse in 2D plots. Supports plotyy, loglog, subplot, etc.
1.6K 次下载
更新时间 2018/3/14

查看许可证

allows direct zooming and panning with the mouse in 2D plots.
Default mouse button functions (can be customized, see below):
Scroll wheel: zoom in/out
Left Mouse Button: select an ROI rectangle to zoom in
Middle Mouse Button: pan view
Right Mouse Button: reset view to default view
SYNTAX:
akZoom
akZoom(___, handles, ___)
akZoom(___, mButtons_ZoomPanReset, ___)
akZoom(___, zoom_direction, ___)
Note: all input arguments are optional and can be given in arbitrary
order.

DESCRIPTION:
akZoom() activates mouse control for all axes-objects in the current
figure with default settings.

akZoom(___, handles, ___)
activates mouse control only for the axes given by the handles
argument which can be:
a) a single axis handle.
b) an array of axis handles. In this case all axes will be linked,
i.e. panning and zooming in one of the axes will affect the others as well.
c) a cell array consisting of axis handles and/or arrays of axis
handles. In this case mouse control is activated for all axes inside
the cell but linking is only activated for axes in a common array.
d) one of the following strings:
i) 'all': activates mouse control for all axes in all open figures.
The axes will not be linked except for axes belonging to the same
plotyy-plot or yyaxis-axes
ii) 'all_linked': activates mouse control for all axes in all open
figures and links all axes.

akZoom(___, mButtons_ZoomPanReset, ___)
will use akZoom with customized mouse buttons.
mButtons_ZoomPanReset can be:
'lmr', 'lrm', 'mlr', 'mrl', 'rlm' or 'rml'
where the letters stand for the left, middle and right mouse buttons
So 'lmr' means: left=ROI-zoom, middle=pan and right=reset.
Note: If you want to use a certain mouse button pattern as default,
just change mButtons_ZoomPanReset_default in the "Settings" section
below.

akZoom(___, zoom_direction, ___)
will use akZoom with zooming only along the specified direction.
zoom_direction can be: 'x', 'y', or 'xy'
Note: If you want to use a certain zoom direction as default, just
change zoom_direction_default in the "Settings" section below.

For further customization check the "Settings" section in the code.

EXAMPLES:
%% Simple Plot
figure
plot(10:24,rand(1,15));
akZoom();

%% Subplots (independent zooming for the axes)
figure
for k = 1:4
y = rand(1,15);
subplot(2, 2, k);
plot(y);
end
akZoom();

%% Subplots (mixture of linked and independent zomming for the axes)
figure
ax = NaN(4,1);
for k = 1:4
y = rand(1,15);
ax(k) = subplot(2, 2, k);
plot(y);
end
akZoom({[ax(1),ax(3)],ax(2),[ax(3),ax(4)]});

%% Different figures (linked)
figure;
imshow(imread('peppers.png'));
ax1 = gca;
figure
imshow(rgb2gray(imread('peppers.png')));
ax2 = gca;
akZoom([ax1,ax2]);

%% Zoom only along the x-axis
figure
plot(log(1:150),rand(1,150));
akZoom('x');

%% Find more examples in the file "akZoom_examples.m"

KNOWN BUGS:
- none at the moment

Author: Alexander Kessel
Affiliation: Max-Planck-Institut für Quantenoptik, Garching, München
Contact : alexander.kessel <at> mpq.mpg.de

CREDITS:
- Rody P.S. Oldenhuis for his mouse_figure function which served as the
template for akZoom
- Benoit Botton for reporting on an issue with axes nested in GUIs
- Anne-Sophie Girard-Guichon for reporting and fixing a bug occuring when
fast scrolling with mouse wheel
- useruser for the simplfication of the wrapper functions

引用格式

Alexander Kessel (2024). akZoom (https://www.mathworks.com/matlabcentral/fileexchange/41426-akzoom), MATLAB Central File Exchange. 检索来源 .

MATLAB 版本兼容性
创建方式 R2016b
兼容任何版本
平台兼容性
Windows macOS Linux
致谢

参考作品: Mouse-friendly FIGURE

启发作品: MousePanningExample, UISignalBuilder2

Community Treasure Hunt

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

Start Hunting!
版本 已发布 发行说明
1.10.1.0

updated file

1.10.0.0

* constraining the zoom to only the x- or y-axis now supported
* in xy-zoom mode the user can constrain the zoom to one axis by drawing an ROI rectangle that spreads over more than 95% of the plot height or width
* the wrappers are simplified

1.9.0.0

fix a bug that occurs when fast scrolling with mouse wheel (thanks to Anne-Sophie Girard-Guichon)

1.8.1.0

included missing file: plotyy_fixZoom.m

1.8.0.0

* solved problems with axes nested in GUIs (thanks to Benoit Botton)
* solved problems with out-of bounds logarithmic-plots
* improved error handling in wrapper functions
* bugfix for fast scrolling (could previously result in error messages )

1.7.0.0

*supports now loglog & semilog
*mouse buttons customizable
*unsensitive to data markers & legends
*checks for valid axis limits (log!)
*automatically callable for 2D plots

1.6.0.0

updated Description

1.5.0.0

-zooming: replaced patch by rectangle -> faster, visually not dependent on renderer, bug fixed that prevented scroll wheel events after zoom
-mapping of mouse buttons can be customized
-easy usage with 'all' and 'all_linked' (works now with plotyy)

1.3.0.0

*bugfixes
*out-of-the-box functionality with subplots and (multiple) plotyy-axes
*arbitraty linking between different axes can be easily set up

1.0.0.0