MATLAB Answers

App Designer: XY Zoom and XY Pan settings

14 views (last 30 days)
mackhina
mackhina on 19 Jan 2020
Commented: Nishant Gupta on 23 Jan 2020
Hi everyone,
Is there a way to lock/choose the XY settings for the zoom and pan features when viewing a 3D surf plot in App Designer?
scroll.png
Using the zoom in the App Designer is giving me big holes in the middle of my surf plots that I don't know how to stop? Any help would be greatly appreciated!
contour hole.png
Thanks in advance!
Cheers

  0 Comments

Sign in to comment.

Accepted Answer

mackhina
mackhina on 22 Jan 2020
Edited: mackhina on 23 Jan 2020
This solutions seems to work to maintain the Z-Axis for both the zoom and pan: UIAxes' YLim property cannot be listened to
I added the function to app designer:
function [inclusivezlim] = mapholdaltlims(app,ax)
objwithz = findobj(app.UIAxes.Children,'-property','ZData');
currmin_z = 0;
currmax_z = 0;
for i = 1:length(objwithz)
currmin_z = min([min(min(objwithz(i).ZData)), currmin_z]);%Need double mins because data could be 2d surface
currmax_z = max([max(max(objwithz(i).ZData)), currmax_z]);
end
inclusivezlim = [currmin_z currmax_z];
ax.ZLim = inclusivezlim;
end
And included the following in each of my plot functions:
warning('off','MATLAB:structOnObject');
warning('off','MATLAB:ui:javaframe:PropertyToBeRemoved'); % Added to turn off java warning
addlistener(struct(app.UIAxes).Axes, 'ZLim', 'PostSet', @(src,evnt)mapholdaltlims(app,app.UIAxes));
There is a delay after zooming/panning, when the Z-Axis is replotted, so it's not the fastest solution, but it does works!
Getting lots of warnings that I don't understand either? Does this mean this function will not work in future versions of Matlab?
Warning: The JavaFrame figure property will be removed in a future release. For more information, see
Recommendations for Java and ActiveX Users on mathworks.com.
> In func_name/startupFcn (line 76)
In appdesigner.internal.service/AppManagementService/tryCallback (line 336)
In matlab.apps/AppBase/runStartupFcn (line 41)
In func_name (line 565)
In appdesigner.internal.service/AppManagementService/runAppWithTryCatch (line 161)
In appdesigner.internal.service/AppManagementService/runDesktopApp (line 89)
In appdesigner.internal.model/AppModel/runAppHelper (line 649)
In appdesigner.internal.model.AppModel>@()appdesigner.internal.model.AppModel.runAppHelper(obj,appArguments) (line 509)

  1 Comment

Nishant Gupta
Nishant Gupta on 23 Jan 2020
Hi,
Since the callback is involved So, it might take the time to load the data and process it according to the callback function. This might be the reason its slow. The Last warnings are because of the warning function that is created as it access JavaFrame and it may not be there in future release.

Sign in to comment.

More Answers (2)

Nishant Gupta
Nishant Gupta on 22 Jan 2020
Hi,
Most probably its because clipping of the plot is taking place when you are zooming in, just set 'clipping' property of UIaxes to 'off'.
app.UIAxes.Clipping = 'off';

  0 Comments

Sign in to comment.


mackhina
mackhina on 22 Jan 2020
That stops the clipping in the Z axis, but I get axes now show through the plot when I zoom in, so the data isn't really useable from an end user perspective :(

  0 Comments

Sign in to comment.

Products


Release

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by