필터 지우기
필터 지우기

zoom and view[90 90 ] problem on figure

조회 수: 3 (최근 30일)
Boissonneau
Boissonneau 2021년 10월 21일
댓글: Boissonneau 2024년 4월 22일
hi,
my problem : when i used view properties on axes, the zoom doesn't work well.
with this code, if i zoom on the third axes, the size of the plot increase, but there is no zoom action
thanks for your help
function TestZoomPlot
x = linspace(-5,5);
y = -1 * x.^2;
ax1 = subplot(2,2,1);
hz = zoom;
plot(x,[y ; y+1]);
title 'Axe 1';
set(ax1,'ButtonDownFcn',@click_1)
setAxesZoomMotion(hz,ax1,'horizontal');
ax3 = subplot(2,2,3);
plot(x,[y ; y+1]);
title 'Axe 3';
setAxesZoomMotion(hz,ax3,'Vertical');
set(ax3,'view',[90 90]);
ax4 = subplot(2,2,4);
plot(x,-[y ; y+1]);
title 'Axe 4';
%set(ax4,'ButtonDownFcn',@click_4)
end

답변 (1개)

Rishav
Rishav 2024년 4월 15일
Hi Boissonneau,
When you set the view of ax3 to [90 90], you are effectively looking at the plot from a top-down perspective, which can interfere with how MATLAB's zoom feature expects to manipulate the camera view and limits.
Here is a simpler adjustment to the code that maintains the use of MATLAB's built-in zoom functionality but removes the custom view setting that is causing the issue:
function TestZoomPlot
x = linspace(-5,5);
y = -1 * x.^2;
% First subplot
ax1 = subplot(2,2,1);
hz = zoom;
plot(x,[y ; y+1]);
title 'Axe 1';
set(ax1,'ButtonDownFcn',@click_1)
setAxesZoomMotion(hz,ax1,'horizontal');
% Third subplot
ax3 = subplot(2,2,3);
plot(x,[y ; y+1]);
title 'Axe 3';
setAxesZoomMotion(hz,ax3,'Vertical');
% Commented out to avoid zoom issues
% set(ax3,'view',[90 90]);
% Fourth subplot
ax4 = subplot(2,2,4);
plot(x,-[y ; y+1]);
title 'Axe 4';
end
The callback function click_1 is referenced but not fully implemented in the provided code. Ensure you have a suitable function defined to handle the click events in your application.
  댓글 수: 1
Boissonneau
Boissonneau 2024년 4월 22일
Thanks Rishav for your help, But the problem was to use the zoom tool with the view function, beacause i wanted to rotate the third axe...

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Data Exploration에 대해 자세히 알아보기

제품


릴리스

R2011b

Community Treasure Hunt

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

Start Hunting!

Translated by