Borrar filtros
Borrar filtros

How to generate three figures to fill the screen (distributed vertically)?

5 visualizaciones (últimos 30 días)
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:
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:
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.

Respuestas (2)

Voss
Voss el 31 de Oct. de 2023
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.

Les Beckham
Les Beckham el 31 de Oct. de 2023
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.

Categorías

Más información sobre Interactive Control and Callbacks en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by