MATLAB Answers

8

How do I make a figure full screen programmatically in MATLAB?

I would like to make my figure "full screen" without using the mouse to maximize the figure window.

8 Answers

Answer by MathWorks Support Team on 18 Oct 2013
 Accepted Answer

To make a figure the same size as your screen in MATLAB execute the following 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.

  3 Comments

How do I name that figure some number like I do when I write "figure(2)", "figure(3)", etc.? When I use this command, it just makes this figure the next number in line.
I hope this helps:
hFig = figure('Name','25');

Sign in to comment.



set(gcf, 'Position', get(0, 'Screensize'));

  3 Comments

Well, that's a smarter solution. Thanks!
In MS Windows and in OS-X, this does not make the window "full screen". Instead, it makes the window "all of the screen except for the title bar or bottom bar or dock". You need special methods to go full screen.
This one is actually way better than the one verified above. Great job, thanks!

Sign in to comment.


Answer by Bogdan Dzyubak on 16 Aug 2016
Edited by Bogdan Dzyubak on 16 Aug 2016

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:
figure;
pause(0.00001);
frame_h = get(handle(gcf),'JavaFrame');
set(frame_h,'Maximized',1);

  0 Comments

Sign in to comment.


Answer by Steven Lord
on 26 Apr 2018

It is possible to do this as of release R2018a using the WindowState property of a figure object.

  0 Comments

Sign in to comment.


Answer by 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.

  0 Comments

Sign in to comment.


Answer by Dominik Mattioli on 20 Jun 2019 at 15:16
Edited by Dominik Mattioli on 20 Jun 2019 at 15:16

If you want to account for the taskbar (I found this in the comments of some other question):
fh = figure();
fh.WindowState = 'maximized';

  1 Comment

Thank you! This solved my issue resizing the "roipoly" figure UI.

Sign in to comment.


Answer by WCJHunter on 27 Jan 2019

As steven lord above said:
set(gcf,'WindowState','fullscreen')

  0 Comments

Sign in to comment.


Answer by Martin Leo on 21 Mar 2019
Edited by Martin Leo on 21 Mar 2019

To open a fullscreen figure window in MATLAB, use the "Position" option of the figure command. There are two way:
  1. Get the screen size and give it to figure:
s = get(0, 'ScreenSize');
figure('Position', [0 0 s(3) s(4)]);
2. Without bothering to get the screen size, use normalized units:
figure('Units','normalized','Position',[0 0 1 1])

  1 Comment

This will give you "full screen except for the title bar or dock or bottom bar". You need other techniques for true full screen.

Sign in to comment.