Matlab returns incorrect figure size when using figure with custom toolbar
12 views (last 30 days)
Show older comments
Hello all,
I created my own GUI using guide which consists of two figures of the same height which I keep attached to each other. One of these figures I have equipped with a custom toolbar. I found that when saving the figure with custom toolbar and then reopening the resulting FIG file, the height has shrunk, in my case by 27 pixels. In fact, when requesting the position information for the figures, the value returned for the height is incorrect! It appears Matlab does not take into account the toolbar dimensions.
Is anyone familiar with this issue? I'm using R2017a.
2 Comments
Rik
on 6 Jan 2020
Which exact properties are you retrieving? And what is your exact goal with saving the GUI as a fig file?
It also sound like whatever you are trying to do is much too complicated for GUIDE to be an effective tool. Consider building your GUI from code instead. For an outline of your options, read this.
Answers (1)
Constantino Carlos Reyes-Aldasoro
on 6 Jan 2020
I would support the idea of doing this through code. What you also do is once you have generated the GUI, grab the handles of the figure.
>> handleFig = gcf;
or if you are starting with a new figure
>> handleFig = figure();
Then you can check the dimensions of the figure:
>> handleFig.Position
ans =
440 378 560 420
And save those values in some way so that when you re-open you can re-size your figure. Please notice that those values are absolute, so they depend on your configuration, e.g. in my case
>> h0 = get(0);
>> h0.ScreenSize
ans =
Columns 1 through 3
1 1 1440
Column 4
900
Hope that helps
0 Comments
See Also
Categories
Find more on Interactive Control and Callbacks in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!