How to Maximize Figure in MATLAB

Ammar Ali Feb 02, 2024
How to Maximize Figure in MATLAB

In this tutorial, we will discuss how to maximize a figure using the figure() function in MATLAB.

Maximize a Figure Using the figure() Function in MATLAB

If you want to maximize a figure, you can use the figure() function. To maximize a figure, you need to use the units and outerposition properties. The units property sets the figure units, and the outerpostion property sets the outer position of the figure on the screen. For example, let’s plot a sine wave on a maximized figure. See the code below.

t = 1:0.01:2;
x = sin(2*pi*t);
figure('units','normalized','outerposition',[0 0 1 1])
plot(t,x)

Output:

Maximizing a Figure

In the above code, we have plotted a sine wave on a maximized figure. Every plot() function below a figure() will plot the data on the same figure. If you want to plot on a new figure, then you have to create it using the figure() function. You can also give a name to the figure using the Name property. You can change the position of the figure using the Position property, and you can change the units of the figure using the Units property. Check this link for more details about the figure() function. You can also use the set() function to maximize your figure anytime in the code. See the code below.

set(gcf,'units','normalized','outerposition',[0 0 1 1])
Author: Ammar Ali
Ammar Ali avatar Ammar Ali avatar

Hello! I am Ammar Ali, a programmer here to learn from experience, people, and docs, and create interesting and useful programming content. I mostly create content about Python, Matlab, and Microcontrollers like Arduino and PIC.

LinkedIn Facebook

Related Article - MATLAB Figure