MATLAB Functions | Help Desk |
figure
Create a Figure graphics objectfigure figure('PropertyName',PropertyValue,...) figure(h) h = figure(...)
figure
is the function for creating Figure graphics objects. Figure objects are the individual windows on the screen in which MATLAB displays graphical output.
figure
creates a new Figure object using default property values.
figure('PropertyName',PropertyValue,...)
creates a new Figure object using the values of the properties specified. MATLAB uses default values for any properties that you do not explicitly define as arguments.
figure(h)
does one of two things, depending on whether or not a Figure with handle h exists. If h is the handle to an existing Figure, figure(h) makes the Figure identified by h
the current Figure, makes it visible, and raises 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. figure(h) where h is not the handle to a Figure, and is not an integer, is an error.
h = figure(...)
returns the handle to the Figure object.
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 the "Figure Properties" section 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.
To create a Figure one quarter the size of your screen, positioned in the upper-left corner, use the Root object's ScreenSize
property to determine the size:
scrsz = get(0,'ScreenSize'); figure('Position',[1 scrsz(4)/2 scrsz(3)/2 scrsz(4)/2])
ScreenSize
is a four-element vector: [left, bottom, width, height]
.set(0,'DefaultFigureProperty',PropertyValue...)Where Property is the name of the Figure property and
PropertyValue
is the value you are specifying.
This section lists property names along with the type of values each accepts. Curly braces { } enclose default values.
BackingStore
{on} | off
Off screen pixel buffer. When BackingStore
is on
, MATLAB stores a copy of the Figure window in an off-screen pixel buffer. When obscured parts of the Figure window are exposed, MATLAB copies the window contents from this buffer rather than regenerating the objects on the screen. This increases the speed with which the screen is redrawn.
BackingStore
to off
to disable this feature and release the memory used by the buffers. If your computer does not support backingstore, setting the BackingStore
property results in a warning message, but has no other effect.
Setting BackingStore
to off
can increase the speed of animations because it eliminates the need to draw into both an off-screen buffer and the Figure window.
BusyAction
cancel | {queue}
Callback routine interruption. The BusyAction
property enables you to control how MATLAB handles events that potentially interrupt executing callback routines. If there is a callback routine executing, subsequently invoked callback routes always attempt to interrupt it. If the Interruptible
property of the object whose callback is executing is set to on
(the default), then interruption occurs at the next point where the event queue is processed. If the Interruptible
property is off
, the BusyAction
property (of the object owning the executing callback) determines how MATLAB handles the event. The choices are:
cancel
- discard the event that attempted to execute a second callback routine.
queue
- queue the event that attempted to execute a second callback routine until the current callback finishes.
ButtonDownFcn
stringButton press callback function. A callback routine that executes whenever you press a mouse button while the pointer is in the Figure window, but not over descendent object (i.e., Uicontrol, Axes or Axes child). Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.
Children
vector of handles Children of the Figure. A vector containing the handles of all Axes, Uicontrol, and Uimenu objects displayed within the Figure. You can change the order of the handles and thereby change the stacking of the objects on the display.
Clipping
{on} | off
This property has no effect on Figures.
CloseRequestFcn
string
Callback executed on Figure close. This property defines a callback routine that MATLAB executes whenever you issue the close
command (either a close(fig_handle)
or a close
all
) or close a Figure window from the computer's window manager menu. This provides an opportunity for the Figure to, for example, display a yes/no/cancel
dialog box before closing, to abort the deletion of the Figure, or to perform "clean up" before closing. The delete
command unconditionally closes the Figure. The default callback is closereq, which uses:
delete(get(0,'CurrentFigure'))Color
ColorSpec
Background color. This property controls the Figure window background color. You can specify a color using a three-element vector of RGB values or one of MATLAB's predefined names. See the ColorSpec
reference page for more information.
m-by-3 matrix of RGB valuesFigure colormap. This property is an m-by-3 array of red, green, and blue (RGB) intensity values that define m individual colors. MATLAB accesses colors by their row number. For example, an index of 1 specifies the first RGB triplet, an index of 2 specifies the second RGB triplet, and so on. Colormaps can be any length (up to 256 only on MS-Windows and Macintosh), but must be three columns wide. The default Figure colormap contains 64 predefined colors.
Colormaps affect the rendering of Surface, Image, and Patch objects, but generally do not affect other graphics objects. See thecolormap
and ColorSpec
reference pages for more information.
CreateFcn
stringCallback routine executed during object creation. This property defines a callback routine that executes when MATLAB creates a Figure object. You must define this property as a default value for Figures. For example, the statement,
set(0,'DefaultFigureCreateFcn','set(gcbo,''IntegerHandle'',''off '')')defines a default value on the Root level that causes the created Figure to use noninteger handles whenever you (or MATLAB) creates Figure. MATLAB executes this routine after setting all properties for the Figure. Setting this property on an existing Figure object has no effect. The handle of the object whose CreateFcn is being executed is accessible only through the Root CallbackObject property, which can be queried using gcbo. C
urrentAxes
handle of current Axes
Target Axes in this Figure. MATLAB sets this property to the handle of the Figure's current Axes (i.e., the handle returned by the gca
function when this Figure is the current Figure). In all Figures for which Axes children exist, there is always a current Axes. The current Axes does not have to be the topmost axes, and setting an Axes to be the CurrentAxes
does not restack it above all other Axes.
axes
and set
commands. For example, axes(
axes_handle
)
and set(gcf,'CurrentAxes',
axes_handle
)
both make the Axes identified by the handle axes_handle
the current Axes. However, axes(
axes_handle
)
also restacks the Axes above all other Axes in the Figure.
If a Figure contains no Axes, get(gcf,'CurrentAxes')
returns the empty matrix. Note that the gca
function actual creates an Axes if one does not exist.
CurrentCharacter
single character (read only)
Last key pressed. MATLAB sets this property to the last key pressed in the Figure window. CurrentCharacter
is useful for obtaining user input.
urrentMenu
(Obsolete)
This property produces a warning message when queried. It has been superseded by the Root CallbackObject
property.
object handle
Handle of current object. MATLAB sets this property to the handle of the object that is under the current point (see the CurrentPoint
property). This object is the front-most object in the stacking order. You can use this property to determine which object a user has selected. The function gco provides a convenient way to retrieve the CurrentObject of the CurrentFigure.
two-element vector: [x-coordinate, y-coordinate]
Location of last button click in this Figure. MATLAB sets this property to the location of the pointer at the time of the most recent mouse button press. MATLAB updates this property whenever you press the mouse button while the pointer is in a Figure window.
TheCurrentPoint
is measured from the lower-left corner of the Figure window, in units determined by the Units
property.
DeleteFcn
string
Delete Figure callback routine. A callback routine that executes when the Figure object is deleted (e.g., when you issue a delete
or a close
command). MATLAB executes the routine before destroying the object's properties so these values are available to the callback routine.
m-by-3 matrix of RGB values
Colormap used for true-color data on pseudocolor displays. This property defines a colormap that MATLAB uses to dither true-color CData
for display on pseudocolor (8-bit or less) displays. MATLAB maps each RGB color defined as true-color CData
to the closest color in the dithermap. The default Dithermap
contains colors that span the full spectrum so any color values map reasonably well.
DithermapMode
property.
DithermapMode
auto | {manual}
MATLAB generated dithermap. In manual
mode, MATLAB uses the colormap defined in the Dithermap
property to display direct color on pseudocolor displays. When DithermapMode
is auto
, MATLAB generates a dithermap based on the colors currently displayed. This is useful if the default dithermap does not produce satisfactory results.
manual
and save the generated dithermap (which MATLAB loaded into the Dithermap
property).
FixedColors
m-by-3 matrix of RGB values (read only)Non-colormap colors. Fixed colors define all colors appearing in a Figure window that are not obtained from the Figure colormap. These colors include axis lines and labels, the color of Line, Text, Uicontrol, and Uimenu objects, and any colors that you explicitly define, for example, with a statement like:
set(gcf,'Color',[.3 .7 .9])
.
Fixed color definitions reside in the system color table and do not appear in the Figure colormap. For this reason, fixed colors can limit the number of simultaneously displayed colors if the number of fixed colors plus the number of entries in the Figure colormap exceed your system's maximum number of colors.
(See the ScreenDepth
property of the Root for information on determining the total number of colors supported on your system. See the MinColorMap
and ShareColors
properties for information on how MATLAB shares colors between applications.)
HandleVisibility
{on} | callback | off
Control access to object's handle by command-line users and GUIs. This property determines when an object's handle is visible in its parent's list of children. Handles are always visible when HandleVisibility
is on
. When HandleVisibility
is callback
, handles are visible from within callbacks or functions invoked by callbacks, but not from within functions invoked from the command line - a useful way to protect GUIs from command-line users, while permitting their callbacks complete access to their own handles. Setting HandleVisibility
to off
makes handles invisible at all times - which is occasionally necessary when a callback needs to invoke a function that might potentially damage the UI, and so wants to temporarily hide its own handles during the execution of that function.
callback
or off
, the object's handle does not appear in its parent's Children
property, Figures do not appear in the Root's CurrentFigure
property, objects do not appear in the Root's CallbackObject property or in the Figure's CurrentObject property, and Axes do not appear in their parent's CurrentAxes
property.
The Root ShowHiddenHandles
property can be set to on to temporarily make all handles visible, regardless of their HandleVisibility settings (this does not affect the values of the HandleVisibility properties).
Handles that are hidden are still valid. If you know an object's handle, you can set
and get
its properties, and pass it to any function that operates on handles. This property is useful for preventing command-line users from accidently drawing into or deleting a Figure that contains only user interface devices (such as a dialog box).
IntegerHandle
{on} | off
Figure handle mode. Figure object handles are integers by default. When creating a new Figure, MATLAB uses the lowest integer that is not used by an existing Figure. If you delete a Figure, its integer handle can be reused.
If you set this property tooff
, MATLAB assigns nonreusable real-number handles (e.g., 67.0001221) instead of integers. This feature is designed for dialog boxes where removing the handle from integer values reduces the likelihood of inadvertently drawing into the dialog box.
Interruptible
{on} | off
Callback routine interruption mode. The Interruptible
property controls whether a Figure callback routine can be interrupted by subsequently invoked callback routines. Only callback routines defined for the ButtonDownFcn
, KeyPressFcn
, WindowButtonDownFcn
, WindowButtonMotionFcn
, and WindowButtonUpFcn
are affected by the Interruptible
property. MATLAB checks for events that can interrupt a callback routine only when it encounters a drawnow
, figure
, getframe
, or pause
command in the routine. See the EventQueue
property for related information.
{on} | off
Change hardcopy to black objects on white background. This property affects only printed output. Printing a Figure having a background color (Color
property) that is not white results in poor contrast between graphics objects and the Figure background and also consumes a lot of printer toner.
InvertHardCopy
is on
, MATLAB eliminates this effect by changing the color of the Figure and Axes to white and the axis lines, tick marks, axis labels, etc., to black. Lines, Text, and the edges of Patches and Surfaces may be changed depending on the print
command options specified.
If you set InvertHardCopy
to off
and specify the -exact
option with the print
command, the printed output matches the colors displayed on the screen (which may be dithered on black and white devices).
See the print
reference page for more information on printing MATLAB Figures.
KeyPressFcn
string
Key press callback function. A callback routine invoked by a key press occurring in the Figure window. You can define KeyPressFcn
as any legal MATLAB expression or the name of an M-file.
CurrentCharacter
property to determine what particular key was pressed and thereby limit the callback execution to specific keys.
The callback routine can also query the Root object's PointerWindow
property to determine in which Figure the key was pressed. Note that pressing a key while the pointer is in a particular Figure window does not make that Figure the current Figure (i.e., the one referred by the gcf
command).
MenuBar
none | {figure}
Enable-disable Figure menu bar. This property allows you to display or hide the menu bar placed at the top of a Figure window. Note that not all systems support Figure window menu bars. However, for those that do, the default is to display the menu.
MinColormap
scalar (default = 64)
Minimum number of color table entries used. This property specifies the minimum number of system color table entries used by MATLAB to store the colormap defined for the Figure (see the ColorMap
property). In certain situations, you may need to increase this value to ensure proper use of colors.
MinColorMap
equal to the length of the colormap:
set(gcf,'MinColormap',length(get(gcf,'ColorMap')))Note that the larger the value of
MinColorMap
, the greater the likelihood other windows (including other MATLAB Figure windows) will display in false colors.
Name
string
Figure window title. This property specifies the title displayed in the Figure window. By default Name
is empty and the Figure title is displayed as Figure
No.
1
, Figure
No.
2
, and so on. When you set this parameter to a string, the Figure title becomes Figure
No.
1:
<
string>
. See the NumberTitle
property.
{add} | replace | replacechildren
How to add next plot. NextPlot
determines which Figure MATLAB uses to display graphics output. If the value of the current Figure is:
add
-- use the current Figure to display graphics (the default).
replace
-- reset all Figure properties, except Position
, to their defaults and delete all Figure children before displaying graphics (equivalent to clf reset
).
replacechildren
-- remove all child objects, but do not reset Figure properties (equivalent to clf
).
newplot
function provides an easy way to handle the NextPlot
property. Also see the NextPlot
property of Axes.
NumberTitle
{on} | off
Figure window title number. This property determines whether the string Figure No. N
(where N
is the Figure number) is prefixed to the Figure window title. See the Name
property.
{portrait} | landscape
Horizontal or vertical paper orientation. This property determines how printed Figures are oriented on the page. portrait
orients the longest page dimension vertically; landscape
orients the longest page dimension horizontally.
4-element rect vectorLocation on printed page. A rectangle that determines the location of the Figure on the printed page. Specify this rectangle with a vector of the form
rect = [left, bottom, width, height]
where left
specifies the distance from the left side of the paper to the left side of the rectangle and bottom
specifies the distance from the bottom of the page to the bottom of the rectangle. Together these distances define the lower-left corner of the rectangle. width
and height
define the dimensions of the rectangle. The PaperUnits
property specifies the units used to define this rectangle.
PaperPositionMode
auto | {manual}
WYSIWYG printing of Figure. In manual
mode, MATLAB honors the value specified by the PaperPosition
property. In auto
mode, MATLAB prints the Figure the same size as it appears on the computer screen, centered on the page.
[width height]
(read only)
Paper size. This property contains the size of the current PaperType
, measured in PaperUnits
.
{usletter} | uslegal | a3 | a4letter | a5
b4 | tabloid
Selection of standard paper size. This property sets the PaperSize
to the one of seven standard sizes. In inches, these sizes are:
usletter
: width = 8.5, height = 11 inches
uslegal
: width = 11, height = 14 inches
a3
: width = 297, height = 420 mm
a4letter
: width = 210, height = 297 mm
a5
: width = 148, height = 210 mm
b4
: width = 250, height = 354 mm
normalized | {inches} | centimeters | points
Hardcopy measurement units. This property specifies the units used to define the PaperPosition
and PaperSize
properties. All units are measured from the lower-left corner of the page. normalized
units map the lower-left corner of the page to (0,0) and the upper-right corner to (1.0,1.0). inches
, centimeters
, and points
are absolute units (one point equals 1/72 of an inch).
PaperUnits
, it is good practice to return it to its default value after completing your computation so as not to affect other functions that assume PaperUnits
is set to the default value.
Parent
handleHandle of Figure's parent. The parent of a Figure object is the Root object. The handle to the Root is always 0.
Pointer
crosshair | {arrow} | watch | topl | topr
| botl | botr | circle | cross | fleur
| left | right | top | bottom | fullcrosshair
| Ibeam | custom
Pointer symbol selection. This property determines the symbol used to indicate the pointer (cursor) position in the Figure window.
SettingPointer
to custom
allows you to define your own pointer symbol. See the PointerShapeCData
property for more information.
PointerShapeCData
16-by-16 matrix
User-defined pointer. This property defines the pointer that is used when you set the Pointer
property to custom
. It is a 16-by-16 element matrix defining the 16-by-16 pixel pointer using the following values:
1
- color pixel black
2
- color pixel white
NaN
- make pixel transparent (underlying screen shows through)
PointerShapeCData
matrix corresponds to the upper-left corner of the pointer. Setting the Pointer
property to one of the predefined pointer symbols does not change the value of the PointerShapeCData
. Computer systems supporting 32-by-32 pixel pointers fill only one quarter of the available pixmap.
PointerShapeHotSpot
2-element vector
Pointer active area. A two-element vector specifying the row and column indices in the PointerShapeCData
matrix defining the pixel indicating the pointer location. The location is contained in the CurrentPoint
property and the Root object's PointerLocation
property. The default value is element (1,1), which is the upper-left corner.
4-element vectorFigure position. This property specifies the size and location on the screen of the Figure window. Specify the position rectangle with a 4-element vector of the form:
rect = [left, bottom, width, height]
where left
and bottom
define the distance from the lower-left corner of the screen to the lower-left corner of the Figure window. width
and height
define the dimensions of the window. See the Units
property for information on the units used in this specification. The left
and bottom
elements can be negative on systems that have more than one monitor.
You can use the get
function to obtain this property and determine the position of the Figure and you can use the set
function
to resize and move the Figure to a new location.
Renderer
painters | zbuffer
Rendering method used for screen and printing. This property enables you to select the method used to render MATLAB graphics. The choices are:
painters
- MATLAB's original rendering method is faster when the Figure contains only simple or small graphics objects.
zbuffer
- MATLAB draws graphics object faster and more accurately because objects are colored on a per pixel basis and MATLAB renders only those pixels that are visible in the scene (thus eliminating front-to-back sorting errors). Note that this method can consume a lot of system memory if MATLAB is displaying a complex scene.
{auto} | manual
Automatic, or user selection of Renderer. This property enables you to specify whether MATLAB should choose the Renderer
based on the contents of the figure window, or whether the Renderer
should remain unchanged.
RendererMode
property is set to auto
, MATLAB selects the rendering method for printing as well as for the screen based on the size and complexity of the graphics objects in the Figure. For printing, MATLAB switches to zbuffer
at a greater scene complexity than for screen rendering because printing from a Z-buffered Figure can be considerably slower than one using the painters
rendering method, and can result in large PostScript files.
When the RendererMode
property is set to manual
, MATLAB does not change the Renderer
, regardless of changes to the Figure contents.
Resize
{on} | off
Window resize mode. This property determines if you can resize the Figure window with the mouse. on
means you can resize the window, off
means you cannot. When Resize
is off
, the Figure window doesn't display any resizing controls (such as boxes at the corners) to indicate the absence of resizeability.
stringWindow resize callback routine. MATLAB executes the specified callback routine whenever you resize the Figure window. The Figure's Position property can be queried to determine the new size and position of the Figure window. The handle to the Figure being resized is only accessible through the Root CallbackObject property, which can be queried using gcbo.
ResizeFcn can be used to maintain a GUI layout that is not directly supported by MATLAB's Position/Units paradigm, such as keeping an object a constant height in pixels, and attached to the top of the Figure, but always matching the width of the Figure. For example, the following ResizeFcn will keep a Uicontrol whose Tag is `StatusBar' 20 pixels high, as wide as the Figure, and attached to the top of the Figure. Note the use of the Tag property to retrieve the Uicontrol handle, and the gcbo function to retrieve the Figure handle. Also note the defensive programming regarding Figure Units, which the callback requires to be in pixels in order to work correctly, but which the callback also restores to their previous value afterwards:u = findobj(`Tag','StatusBar'); fig = gcbo; old_units = get(fig,'Units'); set(fig,'Units','pixels'); figpos = get(fig,'Position'); upos = [0, figpos(4) - 20, figpos(3), 20]; set(u,'Position',upos); set(fig,'Units',old_units);The Figure Position may be changed from within the ResizeFcn callback, however the ResizeFcn will not be called again as a result. Selected
on | off
Is object selected. This property indicates whether the Figure is selected. You can, for example, define the ButtonDownFcn
to set this property, allowing users to select the object with the mouse.
{on} | off
Figures do not indicate selection.
SelectionType
{normal} | extended | alt | open
(read only)Mouse selection type. MATLAB maintains this property to provide information about the last mouse button press that occurred within the Figure window. This information indicates the type of selection made. Selection types are particular actions that are generally associated with particular responses from the user interface software (e.g., single clicking on a graphics object places it in move or resize mode; double-clicking on a filename opens it, etc.).
The physical action required to make these selections varies on different platforms. However, all selection types exist on all platforms.
|
---|
ListBox
style of Uicontrols set the Figure SelectionType
property to normal
to indicate a single mouse click or to open
to indicate a double mouse click.
ShareColors
{on} | off
Share slots in system colortable with like colors. This property affects the way MATLAB stores the Figure colormap in the system color table. By default, MATLAB looks at colors already defined and uses those slots to assign pixel colors. This leads to an efficient use of color resources (which are limited on systems capable of displaying 256 or less colors) and extends the number of Figure windows that can simultaneously display correct colors.
However, in situations where you want to change the Figure colormap quickly without causing MATLAB to re-render the displayed graphics objects, you should disable color sharing (setShareColors
to off
). In this case, MATLAB can swap one colormap for another without changing pixel color assignments since all the slots in the system color table used for the first colormap are replaced with the corresponding color in the second colormap. (Note that is applies only in cases where both colormaps are the same length and where the computer hardware allows user modification of the system color table.)
Tag
string
User-specified object label. The Tag
property provides a means to identify graphics objects with a user-specified label. This is particularly useful when constructing interactive graphics programs that would otherwise need to define object handles as global variables or pass them as arguments between callback routines.
Tag
:
figure('Tag','Plotting Figure')Then make that Figure the current Figure before drawing by searching for the
Tag
with findobj
:
figure(findobj('Tag','Plotting Figure'))Type
string (read only)
Object class. This property identifies the kind of graphics object. For Figure objects, Type
is always the string "figure
".
{pixels} | normal | inches | centimeters | points
Units of measurement. This property specifies the units MATLAB uses to interpret size and location data. All units are measured from the lower-left corner of the window. Normalized (normal
) units map the lower-left corner of the Figure window to (0,0) and the upper-right corner to (1.0,1.0). inches
, centimeters
, and points
are absolute units (one point equals 1/72 of an inch). The size of a pixel
depends on screen resolution.
CurrentPoint
and Position
properties. If you change the value of Units
, it is good practice to return it to its default value after completing your computation so as not to affect other functions that assume Units
is set to the default value.
When specifying the units as property/value pairs during object creation, you must set the Units
property before specifying the properties that you want to use these units.
UserData
matrix
User specified data. You can specify UserData
as any matrix you want to associate with the Figure object. The object does not use this data, but you can access it using the set
and get
commands.
{on} | off
Object visibility. The Visible
property determines whether an object is displayed on the screen. If the Visible
property of a Figure is off
, the entire Figure window is invisible.
stringButton press callback function. Use this property to define a callback routine that MATLAB executes whenever you press a mouse button while the pointer is in the Figure window. Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.
WindowButtonMotionFcn
stringMouse motion callback function. Use this property to define a callback routine that MATLAB executes whenever you move the pointer within the Figure window. Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.
WindowButtonUpFcn
stringButton release callback function. Use this property to define a callback routine that MATLAB executes whenever you release a mouse button. Define this routine as a string that is a valid MATLAB expression or the name of an M-file. The expression executes in the MATLAB workspace.
The button up event is associated with the Figure window in which the preceding button down event occurred. Therefore, the pointer need not be in the Figure window when you release the button to generate the button up event. If the callback routines defined byWindowButtonDownFcn
or WindowButtonMotionFcn
contain drawnow
commands or call other functions that contain drawnow
commands and the Interruptible
property is set to off
, the WindowButtonUpFcn
may not be called. You can prevent this problem by setting Interruptible
to on
.
WindowStyle
{normal} | modal
Normal or modal window behavior. When WindowStyle
is set to modal
, the Figure window traps all keyboard and mouse events over all MATLAB windows as long as it is visible. Windows belonging to other applications other than MATLAB are unaffected. Modal Figures remain stacked above all normal Figures and the MATLAB command window. When multiple modal windows exist, the most recently created window will keep focus and stay above all other windows until it becomes invisible, or is returned to WindowStyle normal
, or is deleted. At that time, focus reverts to the window which last had the focus.
WindowStyle
modal
and Visible
off
do not behave modally until they are made visible, so it is acceptable to hide a modal
window instead of destroying it, for efficiency, when a dialog that is being dismissed may be used again.
The WindowStyle of a Figure may be changed at any time, including when the figure is visible, and contains children. However, on some systems this may cause the figure to flash, or even to disappear and reappear, depending on the windowing-system's implementation of normal and modal windows. For best visual results, WindowStyle should be set at creation time, or when the figure is invisible.
modal
Figures do not display Uimenu children or built-in menus, but it is not an error to create Uimenus in a modal
Figure, or to change WindowStyle
to modal
on a Figure with Uimenu children. The Uimenu objects exist, and their handles are retained by the Figure. If the Figure's WindowStyle
is returned to normal
, the Uimenus will again be displayed.
Modal Figures are used to create dialog boxes that force the user to respond without being able to interact with other windows. Typing Control C at the MATLAB prompt causes all Figures with WindowStyle
modal
to revert to WindowStyle
normal
, to allow typing at the command line.
axes
, uicontrol
, uimenu
, close
, clf
, gcf
, root