Can a UI Figure be centered before displaying?
18 ビュー (過去 30 日間)
古いコメントを表示
I am using movegui(_______,'center') to center my UI figure. While this works, I'd prefer to not have the UI showing at all until the figure is centered. Is this possible?
0 件のコメント
採用された回答
Image Analyst
2019 年 1 月 17 日
編集済み: Image Analyst
2019 年 1 月 17 日
Try this:
h = figure; % Create a figure.
h.Visible = 'off'; % Hide it immediately.
h.Units = 'normalized';
% Get original width and height.
originalSize = h.Position
width = originalSize(3)
height = originalSize(4)
% Reassign the size (optional - only if you want to);
width = .5;
height = 0.3; % Whatever you want.
% Get the left and bottom coordinates so we can reposition to there.
xLeft = 0.5 - width/2;
yBottom = 0.5 - height/2;
% Reposition the figure. Here is where it actually gets moved and (optionally) resized.
h.Position = [xLeft, yBottom, width, height]
h.Visible = 'on'; % Now show it.
1 件のコメント
Cédric Cannard
2023 年 3 月 3 日
Thanks! Even simpler:
h.Visible = 'off'; % hide it immediately
movegui(h,'center') % center
h.Visible = 'on'; % show it
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Contour Plots についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!