I've enabled pan and zoom for a figure but I can only zoom in the figure. How do I pan?

2 次查看(过去 30 天)
I can click and draw a box for a region to zoom in on on the axes window but I can't pan.
close(findall(0,'type','figure','name','EX_ginputWithInteractiveAxes'));
xLbl = 'x-Axis';
yLbl = 'y-Axis';
posSize = [.054 .555 .49 .4];
f = figure('Name','EX_ginputWithInteractiveAxes','NumberTitle','off');
axes_obj = axes('Parent', f, 'Units', 'normalized', 'Position', [posSize(1) posSize(2) posSize(3) posSize(4)],... % Create axes on the desired tab
'Box', 'on', 'XAxisLocation', 'bottom', 'YAxisLocation', 'left','XGrid', 'on', 'YGrid', 'on');
axes_obj.Title.String = 'Path Window';
axes_obj.XLabel.String = sprintf('%s', xLbl); % Put label on X axis
axes_obj.YLabel.String = sprintf('%s', yLbl); % Put label on Y axis
axes_obj.XLim = [-50 50];
axes_obj.YLim = [-50 50];
axes_pan = pan(ancestor(f,'figure'));
axes_pan.Enable = 'on'; % Enable panning for this figure
axes_pan.Motion = 'both'; % Enable vert & horz panning
% Enable Zoom
zoom_obj = zoom(ancestor(f,'figure'));
zoom_obj.Enable = 'on';
zoom_obj.Motion = 'both';

回答(1 个)

Walter Roberson
Walter Roberson 2015-9-9
Zoom and pan are mutually exclusive, since they use the mouse clicks to mean different things.
  2 个评论
Minh Tran
Minh Tran 2015-9-9
That's kind of annoying. So will I have to add a toggle switch to let the user either pan or scroll?
Walter Roberson
Walter Roberson 2015-9-9
You can always program them yourself using callbacks for clicks and mouse motion, if you can come up with an unambiguous set of actions.
The current panning control involves clicking and dragging which changes the xlimit or ylimit axes properties while keeping the difference between the upper and lower limits constant. The xlimit and ylimit properties determine which portion of the data is to be made visible.
The current zoom control involves clicking and dragging to outline a box to be zoomed in on, by setting the xlimit or ylimit axes properties to reflect the coordinates clicked and released at.
There is a defined click/release behaviour for zoom which zooms by a fixed factor near the coordinates clicked at. It would not be entirely inconsistent to say that clicking and releasing in the image was to indicate zooming but that click and drag was to indicate pan. It is possible to come up with consistent and potentially useful behaviour. But with the existing zoom and pan control the meaning of click and drag is different between the two.

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Visual Exploration 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by