Tuesday, August 4, 2009

Figure Properties

Modifying Properties

You can set and query graphics object properties in two ways:

  • The Property Editor is an interactive tool that enables you to see and change object property values.
  • The set and get commands enable you to set and query the values of properties

To change the default value of properties see Setting Default Property Values.

Figure Property Descriptions

This section lists property names along with the type of values each accepts. Curly braces { } enclose default values.

Alphamap m-by-1 matrix of alpha values

Figure alphamap. This property is an m-by-1 array of non-NaN alpha values. MATLAB accesses alpha values by their row number. For example, an index of 1 specifies the first alpha value, an index of 2 specifies the second alpha value, and so on. Alphamaps can be any length. The default alphamap contains 64 values that progress linearly from 0 to 1.

Alphamaps affect the rendering of surface, image, and patch objects, but do not affect other graphics objects.

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.

While refreshing the screen quickly is generally desirable, the buffers required do consume system memory. If memory limitations occur, you can set 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 routines 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 string or function handle

Button 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 a child 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.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

Children vector of handles

Children of the figure. A vector containing the handles of all axes, uicontrol, uicontextmenu, 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 or function handle

Function executed on figure close. This property defines a function that MATLAB executes whenever you issue the close command (either a close(figure_handle) or a close all), when you close a figure window from the computer's window manager menu, or when you quit MATLAB.

The CloseRequestFcn provides a mechanism to intervene in the closing of a figure. It allows you to, for example, display a dialog box to ask a user to confirm or cancel the close operation or to prevent users from closing a figure that contains a GUI.

The basic mechanism is:

  • A user issues the close command from the command line, by closing the window from the computer's window manager menu, or by quiting MATLAB.
  • The close operation executes the function defined by the figure CloseRequestFcn. The default function is named closereq and is predefined as:
    • shh = get(0,'ShowHiddenHandles');
      set(0,'ShowHiddenHandles','on');
      currFig = get(0,'CurrentFigure');
      set(0,'ShowHiddenHandles',shh);
      delete(currFig);

These statements unconditionally delete the current figure, destroying the window. closereq takes advantage of the fact that the close command makes all figures specified as arguments the current figure before calling the respective close request function.

You can set CloseRequestFcn to any string that is a valid MATLAB statement, including the name of an M-file. For example,

  • set(gcf,'CloseRequestFcn','disp(''This window is immortal'')')

This close request function never closes the figure window; it simply echoes "This window is immortal" on the command line. Unless the close request function calls delete, MATLAB never closes the figure. (Note that you can always call delete(figure_handle) from the command line if you have created a window with a nondestructive close request function.)

A more useful application of the close request function is to display a question dialog box asking the user to confirm the close operation. The following M-file illustrates how to do this.

  • % my_closereq
    % User-defined close request function
    % to display a question dialog box

    selection = questdlg('Close Specified Figure?',...
    'Close Request Function',...
    'Yes','No','Yes');
    switch selection,
    case 'Yes',
    delete(gcf)
    case 'No'
    return
    end

Now assign this M-file to the CloseRequestFcn of a figure:

  • set(figure_handle,'CloseRequestFcn','my_closereq')

To make this M-file your default close request function, set a default value on the root level.

  • set(0,'DefaultFigureCloseRequestFcn','my_closereq')

MATLAB then uses this setting for the CloseRequestFcn of all subsequently created figures.

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 the MATLAB predefined names.

Colormap m-by-3 matrix of RGB values

Figure 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), 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 colormap and ColorSpec for more information.

CreateFcn string or function handle

Callback 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) create a 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 you can query using gcbo.

CurrentAxes 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 command 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.

You can make an axes current using the 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. In addition, axes(axes_handle) 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 actually creates an axes if one does not exist.

CurrentCharacter single character

Last key pressed. MATLAB sets this property to the last key pressed in the figure window. CurrentCharacter is useful for obtaining user input.

CurrentMenu (Obsolete)

This property produces a warning message when queried. It has been superseded by the root CallbackObject property.

CurrentObject 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 view. 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.

CurrentPoint 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 the figure window.

In addition, MATLAB updates CurrentPoint before executing callback routines defined for the figure WindowButtonMotionFcn and WindowButtonUpFcn properties. This enables you to query CurrentPoint from these callback routines. It behaves like this:

  • If there is no callback routine defined for the WindowButtonMotionFcn or the WindowButtonUpFcn, then MATLAB updates the CurrentPoint only when the mouse button is pressed down within the figure window.
  • If there is a callback routine defined for the WindowButtonMotionFcn, then MATLAB updates the CurrentPoint just before executing the callback. Note that the WindowButtonMotionFcn executes only within the figure window unless the mouse button is pressed down within the window and then held down while the pointer is moved around the screen. In this case, the routine executes (and the CurrentPoint is updated) anywhere on the screen until the mouse button is released.
  • If there is a callback routine defined for the WindowButtonUpFcn, MATLAB updates the CurrentPoint just before executing the callback. Note that the WindowButtonUpFcn executes only while the pointer is within the figure window unless the mouse button is pressed down initially within the window. In this case, releasing the button anywhere on the screen triggers callback execution, which is preceded by an update of the CurrentPoint.

The figure CurrentPoint is updated only when certain events occur, as previously described. In some situations, (such as when the WindowButtonMotionFcn takes a long time to execute and the pointer is moved very rapidly) the CurrentPoint may not reflect the actual location of the pointer, but rather the location at the time when the WindowButtonMotionFcn began execution.

The CurrentPoint is measured from the lower-left corner of the figure window, in units determined by the Units property.

The root PointerLocation property contains the location of the pointer updated synchronously with pointer movement. However, the location is measured with respect to the screen, not a figure window.

See uicontrol for information on how this property is set when you click on a uicontrol object.

DeleteFcn string or function handle

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.

The handle of the object whose DeleteFcn is being executed is accessible only through the root CallbackObject property, which you can query using gcbo.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

Dithermap 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.

However, if the true-color data contains a wide range of shades in one color, you may achieve better results by defining your own dithermap. See the 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.

The process of generating the dithermap can be quite time consuming and is repeated whenever MATLAB re-renders the display (e.g., when you add a new object or resize the window). You can avoid unnecessary regeneration by setting this property back to manual and save the generated dithermap (which MATLAB loaded into the Dithermap property).

DoubleBuffer on | {off}

Flash-free rendering for simple animations. Double buffering is the process of drawing to an off-screen pixel buffer and then blitting the buffer contents to the screen once the drawing is complete. Double buffering generally produces flash-free rendering for simple animations (such as those involving lines, as opposed to objects containing large numbers of polygons). Use double buffering with the animated objects' EraseMode property set to normal. Use the set command to enable double buffering.

  • set(figure_handle,'DoubleBuffer','on')

Double buffering works only when the figure Renderer property is set to painters.

FileName String

GUI FIG-file name. GUIDE stores the name of the FIG-file used to save the GUI layout in this 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',[0.3,0.7,0.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 root ScreenDepth property 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. HandleVisibility is useful for preventing command-line users from accidentally drawing into or deleting a figure that contains only user interface devices (such as a dialog box).

Handles are always visible when HandleVisibility is on.

Setting HandleVisibility to callback causes handles to be visible from within callback routines or functions invoked by callback routines, but not from within functions invoked from the command line. This provides a means to protect GUIs from command-line users, while allowing callback routines to have complete access to object handles.

Setting HandleVisibility to off makes handles invisible at all times. This may be necessary when a callback routine invokes a function that might potentially damage the GUI (such as evaluating a user-typed string), and so temporarily hides its own handles during the execution of that function.

When a handle is not visible in its parent's list of children, it cannot be returned by functions that obtain handles by searching the object hierarchy or querying handle properties. This includes get, findobj, gca, gcf, gco, newplot, cla, clf, and close.

When a handle's visibility is restricted using 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.

You can set the root ShowHiddenHandles property to on to 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.

HitTest {on} | off

Selectable by mouse click. HitTest determines if the figure can become the current object (as returned by the gco command and the figure CurrentObject property) as a result of a mouse click on the figure. If HitTest is off, clicking on the figure sets the CurrentObject to the empty matrix.

IntegerHandle {on} | off (GUIDE default 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 to off, 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 BusyAction property for related information.

InvertHardcopy {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.

When 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, the printed output matches the colors displayed on the screen.

See print for more information on printing MATLAB figures.

KeyPressFcn string or function handle

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.

The callback routine can query the figure's 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 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).

See Function Handle Callbacks for information on how to use function handles to define the callback function.

MenuBar none | {figure} (GUIDE default is none)

Enable-disable figure menu bar. This property enables you to display or hide the menu bar placed at the top of a figure window. The default (figure) is to display the menu bar.

This property affects only built in menus. Menus defined with the uimenu command are not affected by this property.

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.

For example, suppose you are running color-intensive applications in addition to MATLAB and have defined a large figure colormap (e.g., 150 to 200 colors). MATLAB may select colors that are close but not exact from the existing colors in the system color table because there are not enough slots available to define all the colors you specified.

To ensure MATLAB uses exactly the colors you define in the figure colormap, set 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.

NextPlot {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).

The newplot function provides an easy way to handle the NextPlot property. Also see the NextPlot axes property and Controlling creating_plotsGraphics Output for more information.

NumberTitle {on} | off (GUIDE default 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.

PaperOrientation {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. See the orient command for more detail.

PaperPosition four-element rect vector

Location 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.

PaperSize [width height]

Paper size. This property contains the size of the current PaperType, measured in PaperUnits. See PaperType to select standard paper sizes.

PaperType Select a value from the following table

Selection of standard paper size. This property sets the PaperSize to the one of the following standard sizes.


Property Value
Size (Width x Height)
usletter (default)
8.5-by-11 inches
uslegal
11-by-14 inches
tabloid
11-by-17 inches
A0
841-by-1189mm
A1
594-by-841mm
A2
420-by-594mm
A3
297-by-420mm
A4
210-by-297mm
A5
148-by-210mm
B0
1029-by-1456mm
B1
728-by-1028mm
B2
514-by-728mm
B3
364-by-514mm
B4
257-by-364mm
B5
182-by-257mm
arch-A
9-by-12 inches
arch-B
12-by-18 inches
arch-C
18-by-24 inches
arch-D
24-by-36 inches
arch-E
36-by-48 inches
A
8.5-by-11 inches
B
11-by-17 inches
C
17-by-22 inches
D
22-by-34 inches
E
34-by-43 inches

Note that you may need to change the PaperPosition property in order to position the printed figure on the new paper size. One solution is to use normalized PaperUnits, which enables MATLAB to automatically size the figure to occupy the same relative amount of the printed page, regardless of the paper size.

PaperUnits 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).

If you change the value of 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 handle

Handle 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. Setting Pointer to custom allows you to define your own pointer symbol. See the PointerShapeCData property and Specifying the Figure Pointer 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)

Element (1,1) of the 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.

Position four-element vector

Figure position. This property specifies the size and location on the screen of the figure window. Specify the position rectangle with a four-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 | OpenGL

Rendering method used for screen and printing. This property enables you to select the method used to render MATLAB graphics. The choices are:

  • painters - The original rendering method used by MATLAB 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.
  • OpenGL - OpenGL is a renderer that is available on many computer systems. This renderer is generally faster than painters or zbuffer and in some cases enables MATLAB to access graphics hardware that is available on some systems.

Using the OpenGL Renderer

Hardware vs. Software OpenGL Implementations

There are two kinds of OpenGL implementations - hardware and software.

The hardware implementation makes use of special graphics hardware to increase performance and is therefore significantly faster than the software version. Many computers have this special hardware available as an option or may come with this hardware right out of the box.

Software implementations of OpenGL are much like the ZBuffer renderer that is available on MATLAB version 5.0, however, OpenGL generally provides superior performance to ZBuffer.

OpenGL Availability

OpenGL is available on all computers that MATLAB runs on. MATLAB automatically finds hardware versions of OpenGl if they are available. If the hardware version is not available, then MATLAB uses the software version.

The software versions that are available on different platforms are:

  • On UNIX systems, MATLAB uses the software version of OpenGL that is included in the MATLAB distribution.
  • On MS-Windows, OpenGL is available as part of the operating system. If you experience problems with OpenGL, contact your graphics driver vender to obtain the latest qualified version of OpenGL.

MATLAB issues a warning if it cannot find a usable OpenGL library.

Determining What Version You Are Using

To determine the version and vendor of the OpenGL library that MATLAB is using on your system, type the following command at the MATLAB prompt

  • opengl info

This command also returns a string of extensions to the OpenGL specification that are available with the particular library MATLAB is using. This information is helpful to The MathWorks, so please include this information if you need to report bugs.

OpenGL vs. Other MATLAB Renderers

There are some difference between drawings created with OpenGL and those created with the other renderers. The OpenGL specific differences include:

  • OpenGL does not do colormap interpolation. If you create a surface or patch using indexed color and interpolated face or edge coloring, OpenGL will interpolate the colors through the RGB color cube instead of through the colormap.
  • OpenGL does not support the phong value for the FaceLighting and EdgeLighting properties of surfaces and patches.
  • OpenGL does not support logarithmic-scale axes.

If You Are Having Problems

Consult the OpenGL Technical Note if you are having problems using OpenGL.

RendererMode {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.

When the RendererMode property is set to auto, MATLAB selects the rendering method for printing as well as for screen display 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. However, the output does always match what is on the screen. The same holds true for OpenGL: the output is the same as that produced by the ZBuffer renderer - a bitmap with a resolution determined by the print command's -r option.

Criteria for Autoselection of OpenGL Renderer

When the RendererMode property is set to auto, MATLAB uses the following criteria to determine whether to select the OpenGL renderer:

If the opengl autoselection mode is autoselect, MATLAB selects OpenGL if:

  • The host computer has OpenGL installed and is in True Color mode (OpenGL does not fully support 8-bit color mode).
  • The figure contains no logarithmic axes (logarithmic axes are not supported in OpenGL).
  • MATLAB would select zbuffer based on figure contents.
  • Patch objects faces have no more than three vertices (some OpenGL implementations of patch tesselation are unstable).
  • The figure contains less than 10 uicontrols (OpenGL clipping around uicontrols is slow).
  • No line objects use markers (drawing markers is slow).
  • Phong lighting is not specified (OpenGL does not support Phong lighting; if you specify Phong lighting, MATLAB uses the ZBuffer renderer).

Or

  • Figure objects use transparency (OpenGL is the only MATLAB renderer that supports transparency).

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 does not display any resizing controls (such as boxes at the corners) to indicate that it cannot be resized.

ResizeFcn string or function handle

Window resize callback routine. MATLAB executes the specified callback routine whenever you resize the figure window. You can query the figure's Position property to determine the new size and position of the figure window. During execution of the callback routine, the handle to the figure being resized is accessible only through the root CallbackObject property, which you can query using gcbo.

You can use ResizeFcn to maintain a GUI layout that is not directly supported by the MATLAB Position/Units paradigm.

For example, consider a GUI layout that maintains an object at a constant height in pixels and attached to the top of the figure, but always matches the width of the figure. The following ResizeFcn accomplishes this; it keeps the 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);

You can change the figure Position from within the ResizeFcn callback; however the ResizeFcn is not called again as a result.

Note that the print command can cause the ResizeFcn to be called if the PaperPositionMode property is set to manual and you have defined a resize function. If you do not want your resize function called by print, set the PaperPositionMode to auto.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

See Resize Behavior for information on creating resize functions using GUIDE.

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.

SelectionHighlight {on} | off

figures do not indicate selection.

SelectionType {normal} | extend | alt | open

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


Selection Type
MS-Windows
X-Windows
Normal
Click left mouse button
Click left mouse button
Extend
Shift - click left mouse button or click both left and right mouse buttons
Shift - click left mouse button or click
middle mouse button
Alternate
Control - click left mouse button or click right mouse button
Control - click left mouse button or click
right mouse button
Open
Double click any mouse button
Double click any mouse button

Note that the 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. See uicontrol for information on how this property is set when you click on a uicontrol object.

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 (set ShareColors to off). In this case, MATLAB can swap one colormap for another without changing pixel color assignments because 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 this 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 (GUIDE sets this property)

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.

For example, suppose you want to direct all graphics output from an M-file to a particular figure, regardless of user actions that may have changed the current figure. To do this, identify the figure with a 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'.

UIContextMenu handle of a uicontextmenu object

Associate a context menu with the figure. Assign this property the handle of a uicontextmenu object created in the figure. Use the uicontextmenu function to create the context menu. MATLAB displays the context menu whenever you right-click over the figure.

Units {pixels} | normalized | inches |
centimeters | points | characters
(Guide default characters)

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 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.
  • Characters units are defined by characters from the default system font; the width of one character is the width of the letter x, the height of one character is the distance between the baselines of two lines of text.

This property affects the 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.

Visible {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.

WindowButtonDownFcn string or functional handle

Button 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.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

WindowButtonMotionFcn string or functional handle

Mouse 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.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

WindowButtonUpFcn string or function handle

Button 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 by WindowButtonDownFcn 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.

See Function Handle Callbacks for information on how to use function handles to define the callback function.

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 they are visible. Windows belonging to 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 keeps focus and stays 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 that last had focus.

Figures with 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 when you want to reuse it.

You can change the WindowStyle of a figure at any time, including when the figure is visible and contains children. However, on some systems this may cause the figure to flash or disappear and reappear, depending on the windowing-system's implementation of normal and modal windows. For best visual results, you should set WindowStyle 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 you reset the figure's WindowStyle to normal, the uimenus are displayed.

Use modal figures 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, allowing you to type at the command line.

XDisplay display identifier (UNIX only)

Specify display for MATLAB. You can display figure windows on different displays using the XDisplay property. For example, to display the current figure on a system called fred, use the command:

  • set(gcf,'XDisplay','fred:0.0')
XVisual visual identifier (UNIX only)

Select visual used by MATLAB. You can select the visual used by MATLAB by setting the XVisual property to the desired visual ID. This can be useful if you want to test your application on an 8-bit or grayscale visual. To see what visuals are avail on your system, use the UNIX xdpyinfo command. From MATLAB, type

  • !xdpyinfo

The information returned will contain a line specifying the visual ID. For example,

  • visual id:    0x21

To use this visual with the current figure, set the XVisual property to the ID.

  • set(gcf,'XVisual','0x21')
XVisualMode auto | manual

Auto or manual selection of visual. VisualMode can take on two values - auto (the default) and manual. In auto mode, MATLAB selects the best visual to use based on the number of colors, availability of the OpenGL extension, etc. In manual mode, MATLAB does not change the visual from the one currently in use. Setting the XVisual property sets this property to manual.

No comments:

Post a Comment