Clear Filters
Clear Filters

ライブエディターのF​igureをFigu​reウィンドウで開く​ときの挙動について

10 views (last 30 days)
祐哉
祐哉 on 9 May 2024
Answered: Harimurali on 29 May 2024
ライブエディター上で以下のコードを実行した場合、Figure右上に表示される「Figureウィンドウで開く」をクリックすると、画面の中央付近にウィンドウが表示されるのですが、
f = figure;
surf(peaks)
Figureのサイズを以下のように指定したうえで「Figureウィンドウで開く」をクリックすると、ウィンドウが画面左下に移動されてしまいます。
f = figure;
f.Units = 'centimeters';
f.Position(3:4) = [15 15];
surf(peaks)
一度このような操作を行うと、それ以降は1つ目のコードで作成したFigureを「Figureウィンドウで開く」場合も同様に自動的に左下に移動されます。
しかし、ライブエディター上で
set(f,'visible','on')
を実行してFigureウィンドウを表示すれば、サイズ指定をしていても画面中央付近に表示されました。
また、通常のエディター(スクリプト)であれば、2つ目のコードを実行してもウィンドウが左下に移動することはありませんでした。
MATLABのバージョンは2024a (Appleシリコン)で、2023b以前はこのような挙動にはなりませんでした。
ライブエディターで2つ目のコードのみを実行し「Figureウィンドウで開く」をクリックした場合でもウィンドウが画面中央に表示されるようにするにはどうすればよいでしょうか?

Answers (1)

Harimurali
Harimurali on 29 May 2024
Hi 祐哉,
私の母国語は日本語ではないので、この質問には英語で答えます。
This seems to be an issue with the "Open in figure window" functionality of the figure.
The workaround to open the figure in a figure window and center it is to do it programatically using the following MATLAB functions:
set(f,'visible','on'); % Display the figure in a figure window
movegui(f, 'center'); % Centers the figure window on the screen
The "movegui" function does not seem to be working when you open the figure in a window by clicking on "Open figure window" from the figure in the output pane.
Hope this helps.

Products


Release

R2024a

Community Treasure Hunt

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

Start Hunting!