Why does the figure window with normalized units not open on one screen in MATLAB when using multiple monitors?

11 views (last 30 days)
When I execute the following command:
figure('units','normalized','position',[0 0 1 1]);
The figure window spans across two or more monitors. It should either open up on the current screen or on the other screen(s).
I also made use of the 'Outerposition' property, but it gives me the same results.

Accepted Answer

MathWorks Support Team
MathWorks Support Team on 29 Aug 2019
Edited: MathWorks Support Team on 29 Aug 2019
The ability to use 'normalized' units in this manner to position a figure on only one of multiple monitors is not supported.
In some cases, the 'ScreenSize' property of the root object returns the summed width or height dimensions of the monitors. It is in these cases that the figure window may span the monitors, when created with the 'normalized' units.
One possible workaround is to get the coordinates of the screen where you want the figure window to be displayed, by using the undocumented 'MonitorPositions' property of the root object, which can be accessed with:
get(0,'MonitorPositions');
Then you can position the figure using 'pixel' units instead of 'normalized'.
For example, executing the following:
f = figure('units','normalized','position',[0 0 1 1]);
get(0,'MonitorPositions');
returns:
1 22 1024 746
1025 0 1024 768
To position the figure window on the active monitor, use the following command:
set(f,'units','pixels','position',[1 22 1024 746]);
To position the figure window on the secondary monitor, use the following command:
set(f,'units','pixels','position',[1025 0 1024 768]);

More Answers (0)

Categories

Find more on Specifying Target for Graphics Output in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!