figure
Creates a figure window, or makes an existing one the current figure.
Category: Graphics > Formatting and Annotation
Syntax
figure
Creates a new figure with the next free number and makes it current.
figure(n)
Makes figure number n current, creating it if it does not exist.
figure(Name, Value)
Creates a figure with properties such as 'Name' set.
f = figure(___)
Also returns the figure object.
Description
Plotting commands draw in the current figure, creating one if none exists. Calling figure explicitly lets a script keep several plots apart: each call to figure without an argument opens a new window, and figure(n) goes back to an earlier one to add more to it.
The figure object can be stored and changed through its properties, which is the usual way to set a title or a background color.
Input arguments
n- Positive integer, the figure number.
Name, Value- Figure properties, for example
'Name','Color'or'Position'.
Output arguments
f- Figure object (class
matlab.ui.Figure). ItsNumberproperty holds the figure number.
Example
Named figure and its number
f = figure('Name', 'Demo');
plot(1:5, (1:5).^2)
f.Name
f.Number
Output
ans = 'Demo'
ans = 1