How to generate three figures to fill the screen (distributed vertically)?
조회 수: 7 (최근 30일)
이전 댓글 표시
This should be a very simple problem but I'm not sure if I've done something simple and wrong, or if there is some strange buggy-ness happening.
If I want to generate three figures with the same height and width which fills the full screen then I do this:
close all
ssze=get(groot,'Screensize');
%horizontally distributed (works fine):
%Position = [left bottom width height]
%Each figure is 1/3 of the screenwidth and the full screen height
%The only thing that changes is the left position
f1 = figure('Position',[ 0 0 (1/3)*ssze(3) 1*ssze(4)]);
f2 = figure('Position',[(1/3)*ssze(3) 0 (1/3)*ssze(3) 1*ssze(4)]);
f3 = figure('Position',[(2/3)*ssze(3) 0 (1/3)*ssze(3) 1*ssze(4)]);
No problems here, this results in the expected behavior with no overlap between windows:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1526136/image.png)
However, if I try to do the exact same thing with vertically stacked figures that it doesn't work! In this case, the three figures have the same height and width, but only the bottom coordinate changes:
close all
ssze=get(groot,'Screensize');
%vertically distributed (does not work):
%Position = [left bottom width height]
%Each figure is 1/3 of the screenheight and the full screen width
%The only thing that changes is the bottom position
f1 = figure('Position',[0 0 ssze(3) (1/3)*ssze(4)]);
f2 = figure('Position',[0 (1/3)*ssze(4) ssze(3) (1/3)*ssze(4)]);
f3 = figure('Position',[0 (2/3)*ssze(4) ssze(3) (1/3)*ssze(4)]);
But now I get this:
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/1526141/image.png)
Perhaps its hard to tell, but there is significant overlap between the figures (almost 1/3 of the figures is being covered).
Am I missing something obvious here?
Or is there some problem with the way the screensize is being defined?
Could it be a Mac issue? (Perhaps related to the dock at the bottom or menu bar at the top?)
Any help is appreciated.
댓글 수: 0
답변 (2개)
Voss
2023년 10월 31일
The Position of a figure does not take into account the height of the menu bar or tool bar inside the window (if any), nor the height of the title bar of the window itself (where the name and minimize/maximize/restore/close controls are), nor the size of any border drawn by the operating system around the window.
To attempt to take those into account, you can use OuterPosition instead of Position in your code.
댓글 수: 0
Les Beckham
2023년 10월 31일
When you specify the 'Position' of a figure, that does not include the window title bar, menu, and tool strip, only the part of the window into which the figure will be drawn. Specify the 'OuterPosition' instead.
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Line Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!