How to prevent zooming out past a specific extent in UIAxes?

4 ビュー (過去 30 日間)
meghannmarie
meghannmarie 2020 年 9 月 29 日
コメント済み: meghannmarie 2020 年 10 月 13 日
How do I prevent user from zooming out past an extent in App Designer? In this example I do not want the user to be able to manually zoom out past [180 180] on xaxis or [-90 90] on yaxis. I attached a picture to illustrate.

採用された回答

Nitin Kapgate
Nitin Kapgate 2020 年 10 月 12 日
To limit the user from zooming out past an extent, you can add a custom zoom button (of 'push' button type) to the UIAxes.
In the custom callback for the custom Zoom button, query the current X and Y axis limits for the UIAxes object. If ther X and/or Y limits after zooming out go beyond ehat is required, set the X and Y limits of the UIAxes to the limits you desire.
You can refer this documentation to learn more about adding a custom button to UIAxes.
  2 件のコメント
meghannmarie
meghannmarie 2020 年 10 月 13 日
How do I program the callback function to zoom out? I tried this and it didn't work:
tb = axtoolbar(app.UIAxes,{'zoomin','restoreview'});
btn = axtoolbarbtn(tb,'state');
btn.Icon = 'zoomout';
btn.Tooltip = 'Zoom Out';
btn.ValueChangedFcn = @zoomOut;
function zoomOut
zoom(app.UIAxes,'Direction','out')
end
I have not tried to implement the X/Y limits yet, just trying to get it to zoom out...
meghannmarie
meghannmarie 2020 年 10 月 13 日
I also tried:
set(zoom(app.UIAxes),'ActionPostCallback',@(x,y) zoomLimits(app))
but then I lose ability to zoom completely.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeData Exploration についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by