필터 지우기
필터 지우기

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