How can I stop imagesc from opening empty figure windows in app designer ?

6 views (last 30 days)
Hello !
I'm currentlly having issues with the imagesc command. I use this function to display with specific coordinates an image behind a plot in a UIAxes. However, everytime the imagesc function is called, an additional and unwanted empty figure window is created. (The wanted image is correctly displayed where it should be though)
This is very similar to the behaviour when one forgets to give the handle of the UIAxes like by using:
hold on;
instead of
hold(app.UIAxes, "on");
The syntax I use is the following:
I = imread('image_name.PNG');
imagesc(app.UIAxes, [Xmin Xmax],[Ymin Ymax],I);
To be exact it is more like:
I = imread('image_name.PNG');
uistack(imagesc(app.UIAxes, [Xmin Xmax],[Ymin Ymax],I),'bottom');
But the presence of uistack does not change the behaviour described here.
Does someone have an idea? This is beginning to driving me crazy. Thank you !

Accepted Answer

Kevin Holly
Kevin Holly on 25 Apr 2022
If you look at the documentation for uistack, it states, "The uistack function is not supported in App Designer or in apps created using the uifigure function. Instead, modify the stacking order of components in a container by setting the Children property of the container. For more information, see Change Front-to-Back Component Order."
Pierrekorda on 26 Apr 2022
Edited: Pierrekorda on 26 Apr 2022
The UIAxes has not been renamed. I tried to copy paste your portion of the code to see if I had overlooked an error in the syntax but without much success as the problem still occur.
I, as well, didn't manage to replicate the issue even when by modifying your app and playing with the layout and properties.
I am 100% certain the empty figure window pops up from this line. I will keep looking for it, in the meantime I used:
delete(findall(groot, 'Type', 'figure', 'Number', 1));
To get rid of the undesirable figure, it's not pretty but it works for the time being.
If I ever find the solution I will update this post for future reference. Thank you for the valuable time you took!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!