Documentation Center

  • Trial Software
  • Product Updates

figure

Create figure graphics object

Syntax

figure
figure
figure('PropertyName',propertyvalue,...)
figure(h)
h = figure(...)

Properties

For a list of properties, see Figure Properties.

Description

figure creates figure graphics objects. Figure objects are the individual windows on the screen in which the MATLAB® software displays graphical output.

figure creates a new figure object using default property values. This automatically becomes the current figure and raises it above all other figures on the screen until a new figure is created or called.

figure creates a new figure object using default property values. This automatically becomes the current figure and raises it above all other figures on the screen until a new figure is created or called.

Number property has been assigned the smallest positive integer not already assigned to another Figure. This number also appears in the new Figure's title bar.

figure('PropertyName',propertyvalue,...) creates a new figure object using the values of the properties specified. For a description of the properties, see Figure Properties. MATLAB uses default values for any properties that you do not explicitly define as arguments.

figure(h) does one of the following (assuming IntegerHandle is its default value, on):

  • If h is the handle to an existing figure, figure(h) makes the figure identified by h the current figure, makes it visible, and attempts to raise it above all other figures on the screen. The current figure is the target for graphics output.

  • If h is not the handle to an existing figure, but is an integer, figure(h) creates a figure and assigns it the handle h.

  • If h is not the handle to a figure, and is not an integer, MATLAB returns an error.

h = figure(...) returns the handle to the figure object.

Examples

Specifying Figure Size and Screen Location

To create a figure window that is one quarter the size of your screen and is positioned in the upper left corner, use the root object's ScreenSize property to determine the size. ScreenSize is a four-element vector: [left, bottom, width, height]:

scrsz = get(0,'ScreenSize');
figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])

To position the full figure window including the menu bar, title bar, tool bars, and outer edges, use the OuterPosition property in the same manner.

Specifying the Figure Window Title

You can add your own title to a figure by setting the Name property and you can turn off the figure number with the NumberTitle property:

figure('Name','Simulation Plot Window','NumberTitle','off')

See Figure Properties for a description of all properties.

Setting Default Properties

You can set default figure properties only on the rootobject level.

set(0,'DefaultFigureProperty',PropertyValue...)

where Property is the name of the figure property and PropertyValue is the value you are specifying. Use set and get to access figure properties.

See Setting Default Property Values for more information.

More About

expand all

Tips

To create a figure object, MATLAB creates a new window whose characteristics are controlled by default figure properties (both factory installed and user defined) and properties specified as arguments. See Figure Properties for a description of these properties.

You can specify properties as property name/property value pairs, structure arrays, and cell arrays (see the set and get reference pages for examples of how to specify these data types).

Use set to modify the properties of an existing figure or get to query the current values of figure properties.

The gcf command returns the handle to the current figure and is useful as an argument to the set and get commands.

Figures can be docked in the desktop. The DockControls property determines whether you can dock the figure.

Making a Figure Current

The current figure is the target for graphics output. There are two ways to make a figure h the current figure.

  • Make the figure h current, visible, and displayed on top of other figures:

    figure(h);
  • Make the figure h current, but do not change its visibility or stacking with respect to other figures:

    set(0,'CurrentFigure',h);

See Also

| | | | | | | |

Was this topic helpful?