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

ライブエディター上で以下のコードを実行した場合、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ウィンドウで開く」をクリックした場合でもウィンドウが画面中央に表示されるようにするにはどうすればよいでしょうか?

답변 (1개)

Harimurali
Harimurali 2024년 5월 29일

0 개 추천

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.

카테고리

도움말 센터File Exchange에서 グラフィックス オブジェクトの識別에 대해 자세히 알아보기

제품

릴리스

R2024a

질문:

2024년 5월 9일

답변:

2024년 5월 29일

Community Treasure Hunt

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

Start Hunting!