zoom and view[90 90 ] problem on figure

3 次查看(过去 30 天)
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