figure pop outside the screen

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 Comments

And I am using following code to set default position.
set(0, 'DefaultFigurePosition', [-1500 0 400 300]);
But I don't think this is a fundamental solution.
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 on 5 Feb 2018
Edited: Yoshi Ri on 7 Feb 2018
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.

Sign in to comment.

 Accepted Answer

michio
michio on 6 Feb 2018
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 Comments

Hi michio.
As you said, my screen size is expressed as 'centimeter', so I updated my previous answer to 'pixel' representation. And my environment is as follows:
Windows 10 64bit
MATLAB 2015a student license
Also, I think my startup does not contain any description related to my problem except the last line.
% OpenGL
opengl software
% figure のデフォルトフォント設定
set(0, 'defaultAxesFontSize', 12);
set(0, 'defaultTextFontSize', 12);
set(0, 'defaultAxesFontName','Times-Roman');
set(0,'defaultTextFontName','Times-Roman');
% ブロックのデフォルトフォントを変更
set_param(0,'DefaultBlockFontSize',11);
set_param(0,'DefaultBlockFontName','Times-Roman');
% ラインのデフォルトフォントサイズを変更
set_param(0,'DefaultLineFontSize',9);
set_param(0,'DefaultLineFontName','Times-Roman');
% 注釈のデフォルトフォントサイズを変更
set_param(0,'DefaultAnnotationFontSize',12);
set_param(0,'DefaultAnnotationFontName','Times-Roman');
%LINEwidth
set(0,'defaultLineLineWidth',1.75)
% Position Control
set(0, 'DefaultFigurePosition', [-1500 0 15*40 11*40]);
I am not sure how this prefdir reseting affect to my environment, so I want to know other altanatives if possible. Thank you.
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.
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.

Sign in to comment.

More Answers (1)

Tags

Asked:

on 4 Feb 2018

Edited:

on 2 Feb 2024

Community Treasure Hunt

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

Start Hunting!