How do I make a figure full screen programmatically in MATLAB?
3,583 views (last 30 days)
MathWorks Support Team on 30 Apr 2021
Edited: MathWorks Support Team on 28 Aug 2023 at 13:41
Starting in MATLAB R2018a, you can use the WindowState property to maximize, minimize, or display a figure in full-screen mode.
To make a figure the same size as your screen in previous releases, you may use this command:
figure('units','normalized','outerposition',[0 0 1 1])
Please also see the related solution below for a method of programmatically maximizing, minimizing, and restoring a figure window.
More Answers (6)
Bogdan Dzyubak on 16 Aug 2016
Edited: MathWorks Support Team on 24 Jun 2021
The proposed methods are simple but make the figure "nearly" full screen which can cause you to close the maximized Matlab session instead of the figure.
For actual maximize you can use the following:
frame_h = get(handle(gcf),'JavaFrame');
Jan on 26 Feb 2018
Under Windows you can use the API of the OS, see https://www.mathworks.com/matlabcentral/fileexchange/31437-windowapi :
FigH = figure;
WindowAPI(FigH, 'full'); % fill the current monitor
WindowAPI(FigH, 'work'); % fill the current monitor without taskbar, if there is one
No window border anymore, just the inner position.
DGM on 31 Dec 2020
Similar to Jan's answer, it's possible to use system-level tools to maximize windows in Linux. That way, the behavior should be version-agnostic and will resize the window to the geometry that you'd expect if you just clicked the window maximize button manually.
In order to identify the window externally, simply give the figure window an unambiguous title. Then you can just use wmctrl to fetch the windowid and subsequently maximize the window.
pause(1) % wait for the window manager
system(sprintf('winid=$(wmctrl -lx | grep "%s" | cut -d \\ -f 1 | tail -n 1); wmctrl -ir "$winid" -b add,maximized_vert,maximized_horz',windowname))