Clear Filters
Clear Filters

zoom and view[90 90 ] problem on figure

6 views (last 30 days)
Boissonneau
Boissonneau on 21 Oct 2021
Commented: Boissonneau on 22 Apr 2024
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

Answers (1)

Rishav
Rishav on 15 Apr 2024
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 Comment
Boissonneau
Boissonneau on 22 Apr 2024
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...

Sign in to comment.

Categories

Find more on Visual Exploration in Help Center and File Exchange

Products


Release

R2011b

Community Treasure Hunt

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

Start Hunting!