figure pop outside the screen

106 次查看(过去 30 天)
Hi. I have trouble with a default figure position.
Somehow my figure always comes outside the window. If I reset the default figure position like below, the figure still appears outside the valid screen.
set(0, 'DefaultFigurePosition', [0 0 400 300]);
figure()
Does anybody know the good way to fix this problem?
和文
matlabの図が画面外に出る現象に困っています。 DefaultFigurePositionを設定しても,画面外右に出てくるのでMATLABのディスプレイ認識が間違っているのではと思っていますがPCごと再起動しても改善されません。 どうすればよいでしょうか。
  3 个评论
michio
michio 2018-2-4
This might be related to your issue. Are you using MATLAB via remote access or do you have multiple screens?
What does the following reply?
get(0,'ScreenSize')
Yoshi Ri
Yoshi Ri 2018-2-5
编辑:Yoshi Ri 2018-2-7
Thank you for your comment. Though I read that article, I can not get any idea to solve this situation. Here is my result.
>> get(0,'ScreenSize')
ans =
1 1 1536 864
>> get(0, 'MonitorPositions')
ans =
1 -215 1920 1080
-2399 -485 2400 1350
I use one additional screen at left side of the main screen, and my figure appears on the right side of the main screen.

请先登录,再进行评论。

采纳的回答

michio
michio 2018-2-6
Thanks! I forgot to ask. What version of MATLAB are you using and on what OS?
Also please note that MATLAB sets the display size values for this property at startup. The values are static and your system display settings change do not reflect on those values. MATLAB needs to restart to refresh the value.
See: https://jp.mathworks.com/help/matlab/ref/root-properties.html describes the properties related to the graphics.
One thing caught my attention is your numbers do not seem to be in pixel. As stated in the "Units" property of the following page, 'ScreenSize' and 'MonitorPosition' will in pixel by default setting. Could you try the following to double check?
get(0, 'Units');
get(0, 'MonitorPositions');
I am guessing if your 'Unit' is not in pixels (and if you did't change it), it could indicate that there are some scripts that do changes the graphics properties at start-up. Any ideas?
startup.m is one possibility.
Could you check if you have startup.m by executing
which -all startup
Another thing you can try is to refresh your prefdir folder, which contains preferences, history, and layout file. You can delete the folder and restart MATLAB.
View the location of the preferences folder by
prefdir
  3 个评论
michio
michio 2018-2-7
Just to clarify, what happens if you comment out all the command on your startup.m and restart MATLAB?
Just wanted to double check the values of defaultfigurepositon without startup.
michio
michio 2018-2-7
Also on prefdir, you can make a backup copy of the original folder and put them back later with the same name. Then any setting you currently have will be restored.

请先登录,再进行评论。

更多回答(1 个)

SREEJITH VS
SREEJITH VS 2024-2-2
编辑:SREEJITH VS 2024-2-2
After figure add this line
movegui('center');

类别

Help CenterFile Exchange 中查找有关 グラフィックス オブジェクトのプロパティ 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!