How to permanently fix the position of the plot window ?

조회 수: 35 (최근 30일)
Alice Lemoine
Alice Lemoine 2023년 8월 24일
댓글: Neda 2025년 8월 27일
I wonder if it's possible to set the parameters of display to see the plot window always in the same position. Because I have two displays and I would like to fix the position on my second screen. In addition, when I use only one screen, the plot window exceeds the screen and I don't have access anymore to the window control bar.
Can anyone help me ? Thanks

채택된 답변

Alexander
Alexander 2023년 8월 28일
편집: Alexander 2023년 8월 28일
I think you need this:
set (groot, 'DefaultFigurePosition', p);
You have to put this line in the startup.m.
To get p: Open a figure and move it to the position you want it when plotting. Get the position:
p=(figure(1),''Position');
Hardcopy the content of p in the command above.
In my startup.m are the lines:
p = [-916 571 560 420];
set (groot, 'DefaultFigurePosition', p);
  댓글 수: 5
Alice Lemoine
Alice Lemoine 2023년 8월 28일
it seems working ! thanks a lot !

댓글을 달려면 로그인하십시오.

추가 답변 (1개)

Daniele Sportillo
Daniele Sportillo 2023년 8월 28일
Hi Alice,
the command
groot().MonitorPositions
gives you informations about your screens. Check this: Graphics environment and state information
ans =
1.0e+03 *
-1.9190 0.3557 1.9200 1.0800
0.0010 0.0010 2.5600 1.4400
In my case, I have the principal screen on the right (2nd line) and the secondary screen on the left (1st line).
So if I want to plot on my left screen I do:
fig=figure;
fig.Position = [-1000 500 500 350]; %note the minus sign
ax=axes(fig);
plot(ax,1:5);
To be sure that your plot will be "visible", no matter how many screens you are using, you could clamp the position of your figure into your screens range, like this:
fig.Position = [max(-3000, min(groot().MonitorPositions(:,1))) 500 500 350];
In alternative, you could just use an if-else condition according to the number of your screens:
if size(groot().MonitorPositions,1) == 1 % I am using only one monitor
% fig.Position = ...
else
% fig.Position = ...
end
Hope this helps!
  댓글 수: 2
Alice Lemoine
Alice Lemoine 2023년 8월 28일
thanks a lot ! but I search a solution which fixs the problem for all the time I want to plot figure
Neda
Neda 2025년 8월 27일
Thank you Daniele, very helpful.

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Startup and Shutdown에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by