get zoom status of a UIAxes

4 次查看(过去 30 天)
craq
craq 2018-7-27
回答: Sameer 2025-5-29
For a figure axes, I can find out whether zoom is active or not by doing:
figure
plot(1:10)
h = zoom(gca);
get(h,'Enable') %off
zoom(gca,'on') %start zoom mode
get(h,'Enable') %on
but the equivalent with a UIAxes doesn't seem to work:
>> h = zoom(app.UIAxes)
Error using matlab.ui.control.UIAxes/zoom
Too many output arguments.
How can I find out whether zoom is active on my UIAxes?

回答(1 个)

Sameer
Sameer 2025-5-29
In the case of "UIAxes", we cannot use "zoom(app.UIAxes)" to get the zoom object like we can with regular axes. This will result in an error because "UIAxes" does not support that syntax.
There is no direct way to check if zoom is currently enabled on a "UIAxes". A common workaround is to manage the zoom state manually using a variable.
Here's an example code:
% Enable zoom
zoom(app.UIFigure, 'on');
app.ZoomEnabled = true;
% Later check
if app.ZoomEnabled
disp('Zoom is on');
else
disp('Zoom is off');
end
Hope this helps!

类别

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

Community Treasure Hunt

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

Start Hunting!

Translated by