image thumbnail

DRAGZOOM - Drag and zoom tool

version 1.13.0.0 (18.9 KB) by Evgeny Pr
DRAGZOOM allows you to handy interactively manage the axes in figure.

5.6K Downloads

Updated 05 Jun 2011

View License

Editor's Note: This file was selected as MATLAB Central Pick of the Week

DRAGZOOM allows you to interactively manage the axes in figure. This simple function for usable dragging and zooming of axes, rotate 3D axes, using the mouse and the keyboard shortcuts.

Features:
- Supports 2D-Plots, 3D-plots, Log plots and Images
- Supports multiple mixed (subplots) (2D, 3D) axes on one figure
- Supports X,Y,XY linking of several 2-D axes (Synchronize manage)
- Rubber Band Region Zooming
- Magnifier Tool
- Handy Cross-hair Cursor
- Handy Zooming and Draging Plots
- Handy and Fast Rotate 3D Plots
- Control Enabled Status

----------------------------------------------
Using:
dragzoom()
dragzoom(hFig)
dragzoom(hAx)
dragzoom(hAxes) % array of axes handles
dragzoom(hFig, status) % status - set enable status 'on' or 'off'
dragzoom(status)

----------------------------------------------
Control Enabled Status of DRAGZOOM:
dragzoom(hFig, 'on') % Enable DRAGZOOM for figure "hFig"
dragzoom(hFig, 'off') % Disable DRAGZOOM for figure "hFig"
dragzoom('on') % Enable DRAGZOOM for figure "GCF"
dragzoom('off') % Disable DRAGZOOM for figure "GCF"

----------------------------------------------
Interactive mode:
Available the following actions:

******************************
2D and Image modes:
******************************
- Mouse actions in 2D mode:
-- Normal mode:
"single-click and holding LB" - Activation Drag mode
"single-click and holding RB" - Activation Rubber Band for region zooming
"single-click MB" - Activation 'Extend' Zoom mode
"scroll wheel MB" - Activation Zoom mode
"double-click LB, RB, MB" - Reset to Original View

-- Magnifier mode:
"single-click LB" - Not Used
"single-click RB" - Not Used
"single-click MB" - Reset Magnifier to Original View
"scroll wheel MB" - Change Magnifier Zoom
"double-click LB" - Increase Magnifier Size
"double-click RB" - Decrease Magnifier Size

- Hotkeys in 2D mode:
'+' - Zoom plus
'-' - Zoom minus
'0' - Set default axes (reset to original view)
'uparrow' - Up or down (inrerse) drag
'downarrow' - Down or up (inverse) drag
'leftarrow' - Left or right (inverse) drag
'rightarrow' - Right or left (inverse) drag
'c' - On/Off Pointer Symbol 'fullcrosshair'
'g' - On/Off axes grid (only plots)
's' - On/Off smoothing plots
'x' - If pressed and holding, zoom and drag works only for X axis
'y' - If pressed and holding, zoom and drag works only for Y axis
'm' - If pressed and holding, Magnifier mode on
'l' - On XY / Off X,Y,XY linking 2-D axes (Synchronize manage)
'control+l' - On X linking 2-D axes
'alt+l' - On Y linking 2-D axes

******************************
* 3D Mode:
******************************
- Mouse actions in 3D mode:
"single-click and holding LB" - Activation Drag mode
"single-click and holding MB" - Activation 'Extend' Zoom mode
"single-click and holding RB" - Activation Rotate mode
"scroll whell MB" - Activation Zoom mode
"double-click LB, RB, MB" - Reset to Original View

- Hotkeys in 3D mode:
'+' - Zoom plus
'-' - Zoom minus
'0' - Set default axes (reset to original view)
'uparrow' - Rotate up-down
'downarrow' - Rotate down-up
'leftarrow' - Rotate left-right
'rightarrow' - Rotate right-left
'ctrl'+'uparrow' - Up or down (inrerse) drag
'ctrl'+'downarrow' - Down or up (inverse) drag
'ctrl'+'leftarrow' - Left or right (inverse) drag
'ctrl'+'rightarrow' - Right or left (inverse) drag
'1' - Go to X-Y view
'2' - Go to X-Z view
'3' - Go to Y-Z view
'v' - On/Off Visible Axes
'f' - On/Off Fixed Aspect Ratio
'g' - On/Off Visible Grid

----------------------------------------------
Examples:

% 2D
x = -pi:0.1:pi;
y = sin(x);
figure; plot(x, y);
dragzoom

% Image
I = imread('cameraman.tif');
figure; imshow(I, []);
dragzoom

% 3D
figure;
[X,Y] = meshgrid(-3:.125:3);
Z = peaks(X,Y);
meshc(X,Y,Z);
axis([-3 3 -3 3 -10 10]);
xlabel('x');
ylabel('y');
zlabel('z');
dragzoom;

figure;
x = -pi*2:0.1:pi*2;
y1 = sin(x);
y2 = cos(x);
hax1 = subplot(2,1,1); plot(x,y1, '.-r')
hax2 = subplot(2,1,2); plot(x, y2, 'o-b')
dragzoom(hax1); % manage only axes 1

Cite As

Evgeny Pr (2021). DRAGZOOM - Drag and zoom tool (https://www.mathworks.com/matlabcentral/fileexchange/29276-dragzoom-drag-and-zoom-tool), MATLAB Central File Exchange. Retrieved .

MATLAB Release Compatibility
Created with R2008b
Compatible with any release
Platform Compatibility
Windows macOS Linux

Community Treasure Hunt

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

Start Hunting!