axes position differs between two consecutive GUI executions

Hey,
An axes in my GUI is behaving differently between two consecutive executions of my GUI.
When I start Matlab and then run my GUI, the mentioned axes' position is not where it is supposed to be. When I close the GUI and immediately afterwards restart the GUI the said axes is in its supposed to be position. I can then restart the GUI as often as I want and the axes behaves as expected and is in its right position. It is only when I freshly start Matlab, and right after that the GUI, that it behaves as described above.
I desinged the GUI using GUIDE and I do some GUI initilizations in the OpeningFcn. However, as far as I know I nowhere modify the position of the mentioned axes. GUIDE is the only way I modified the axes position.
I have no idea how to provide a minimal working example to show what I mean. Hence, see the picture below that shows a "Wrong-Right"-screenshot of the GUI to get an impression.
Any idea what the problem might be and how to solve it?
Thank you alot in advance!
Best regards
Hannes

6 Comments

I guess I'm just tired, but honestly I can't see any difference!
The left-most axes is just raised slightly in the left image. So does this appear only on the first time that you run the GUI after having launched MATLAB, and every subsequent time that you launch it (from within that session) the axes is correctly placed? If so, what happens if you start MATLAB, launch the GUI, observe the incorrectly placed axes, then in the Command Window type clear all, and relaunch the GUI. What is the result of the axes position?
Yes, it appears only on the first time that I run the GUI after having launched MATLAB.
As you requested I launched Matlab, started my GUI, (closed it), cleared all via 'clear all' and then relaunched my GUI. After that the axes position was as its supposed to be, correct, no offset or anything.
If we can't find a solution to this problem I thought I can always replace the mentioned axes with a pushbutton (since I use the axes' ButtonDownFcn to use it as a button). It would be really weird if the same problem would remain.
Have you tried programatically setting it's position in the Opening Fcn to what it is supposed to be? Obviously logically that is a silly thing to do since GUIDE already has the correct position, but you never know, it may work.
I have had some issues, not quite like that, but similar with my GUIs where I plot an image and my axes move slightly when the image is plotted. I never looked into why as it seemed to difficult too pin down, but I also hadn't given any position instructions other than those in GUIDE.
(Now that it is morning I can easily see the difference now!!)
I did try to change it by setting the position programmatically in my OpeningFcn - didn't change anything.
I now replaced the axes with a pushbutton. That simplyfied my code and the pushbutton stays where its supposed to be :). I know, that doesn't solve the initial problem of why the axes behaves this weird, its just a workaround. I'm still interested in why the axes is behaving like it does. So if anyone has any thoughts about that I am glad to here them!
Thank you all for your help! :)

Answers (0)

This question is closed.

Asked:

on 26 Sep 2014

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!