Root Properties

Graphics environment and state information

The root object is the root of the graphics object tree. Root properties contain information about the graphics environment and the current state of the graphics system.

Starting in R2014b, you can use dot notation to refer to a particular object and property:

r = groot;
fig = r.Children;

If you are using an earlier release, use the get function to query properties.

Display Information

expand all

MonitorPositionsWidth and height of displaysn-by-4 matrix

This property is read only.

Width and height of displays, returned as an n-by-4 matrix, where n is the number of displays. Each row corresponds to one display and is a four-element vector of the form [x y width height]. For example, if there are two displays, then the matrix has this form:

[x1 y1 width1 height1
 x2 y2 width2 height2]

The first two elements in each row indicate the display location with respect to the origin point. The last two elements in each row indicate the display size. The origin point is the lower-left corner of the primary display. If the units are pixels, then the origin point is (1,1). For all other units, the origin point is (0,0). The Units property determines the units of this measurement.

PointerLocationCurrent location of pointertwo-element vector

Current location of pointer, specified as a two-element vector of the form [x y]. The x and y values are the coordinates of the pointer position measured from the origin point. The origin point is the lower-left corner of the primary display. If the units are pixels, then the origin point is (1,1). For all other units, the origin point is (0,0). The Units property determines the units of this measurement.

This property contains the current pointer location, even if the pointer is outside a MATLAB® window. Move the pointer by changing the values of this property. On Macintosh systems, you cannot change the pointer location by setting this property.

Querying the PointerLocation property in a callback routine might return a value that is different from the location of the pointer when the callback was triggered. This difference results from delays in callback execution caused by competition for system resources.

Example: [500 400]

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

ScreenDepthNumber of bits that define each pixel colorscalar

Number of bits that define each pixel color, specified as a scalar. The default value depends on the computer. The maximum number of simultaneously displayed colors on the current graphics device equals 2 raised to the value of this property.

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

ScreenPixelsPerInchDisplay resolutionscalar

Display resolution, specified as a scalar in pixels per inch. The default value depends on the computer. The value is the setting of the display resolution specified in your system preferences.

Example: 72

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64

ScreenSizeSize of primary displayfour-element vector

This property is read only.

Size of primary display, returned as a four-element vector of the form [left bottom width height] that defines the display size. If the units are pixels, then the first two elements are both 1. For all other units, the first two elements are both 0. The last two elements are the display dimensions in units specified by the Units property.

The values might not represent the usable display size due to the presence of UIs, such as the Microsoft® Windows® task bar.

    Note:   MATLAB sets the display size values at startup. The values are static. If your system display settings change, the display size values do not update.

FixedWidthFontNameFont name for fixed-width fontstring

Font name for fixed-width font, specified as a string giving the name of a system supported font. This property determines the font for axes, text, and uicontrols that have a FontName property set to 'FixedWidth'. The default value depends on the system. 'Courier' is the default in systems that use Latin-based characters.

Specifying the FixedWidthFontName property eliminates the need to hardcode font names in MATLAB applications. These applications can run without modification in systems that require non-ASCII character sets. In these cases, MATLAB attempts to set FixedWidthFontName property to the correct value for the system.

If you are a MATLAB application developer and want to use a fixed-width font, set the FontName property for axes, text, and uicontrol objects to 'FixedWidth' instead of setting this root property. Users of the application can set the root property if they do not want to use the preselected value.

Example: 'Courier New'

UnitsUnits for MonitorPositions, ScreenSize, and PointerLocation'pixels' (default) | 'inches' | 'centimeters' | 'points' | 'characters' | 'normalized'

Units for the MonitorPositions, ScreenSize, and PointerLocation properties, specified as one of the values shown in this table.

UnitsDescription
'pixels' (default)Pixels. Pixel size depends on the display resolution.
'inches'Inches.
'centimeters'Centimeters.
'points'Points. One point equals 1/72 inch.
'normalized'Normalized with respect to the display. The lower-left corner of the display maps to (0,0) and the upper-right corner maps to (1,1).
'characters'Based on the size of characters in the default system font. The width of one character unit is the width of the letter x. The height of one character unit is the distance between the baselines of two lines of text.

All units are measured from the lower-left corner of the primary display. If the units are pixels, then the lower-left corner maps to (1,1). For all other units, the lower-left corner maps to (0,0).

If you change the units, it is good practice to return it to its default value after completing your operation to prevent affecting other functions that assume the Units property is set to the default value.

Parent/Child

expand all

ParentParentempty GraphicsPlaceholder

The root object has no parent. This property is always an empty GraphicsPlaceholder.

ChildrenChildrenempty GraphicsPlaceholder | array of figure objects

Children, specified as an array of figure objects that have visible handles. The HandleVisibility property of the figure determines if the handle is visible or hidden. This property does not contain figures with hidden handles.

Change the order of the children to change the sorting order of the figures on the display.

HandleVisibilityVisibility of root object handle'on' (default) | 'callback' | 'off'

This property has no effect. The root object handle is always visible using the groot function.

ShowHiddenHandlesHidden handle display'off' (default) | 'on'

Hidden handle display, specified as one of these values:

  • 'off' — Do not display hidden object handles. The HandleVisibility property of the object determines if the handle is visible or hidden.

  • 'on' — Expose all object handles regardless of the HandleVisibility property.

Identifiers

expand all

CallbackObjectObject whose callback is executing[] (default) | graphics object

This property is read only.

Object whose callback is executing, returned as a graphics object. For more information, see the gcbo command.

CurrentFigureCurrent figureempty GraphicsPlaceholder (default) | figure object

Current figure, specified as a figure object. The current figure is typically the one most recently created, clicked on, or made current by calling the figure function. Setting this property makes a figure the current figure without sorting it to the front of other figures on the display. However, using the figure function to make a figure the current figure sorts that figure to the front of the display. To become the current figure, the HandleVisibility property of the figure must be set to 'on'.

This property returns an empty GraphicsPlaceholder array if there are no figures. However, the gcf command always returns a figure object. If there are no figure objects, then gcf creates one.

TypeType of graphics object'root'

This property is read only.

Type of graphics object, returned as the string 'root'. The root object handle is always visible using the groot function.

TagTag to associate with root'' (default)

Tag to associate with root, specified as a string. There is only one root object, which you can always access using the groot function.

UserDataData to associate with root[] (default) | scalar, vector, or matrix | cell array | character array | table | structure

Data to associate with the root object, specified as a scalar, vector, matrix, cell array, character array, table, or structure. MATLAB does not use this data.

To associate multiple sets of data or to attach a field name to the data, use the getappdata and setappdata functions.

Example: 1:100

Data Types: single | double | int8 | int16 | int32 | int64 | uint8 | uint16 | uint32 | uint64 | logical | char | struct | table | cell

Was this topic helpful?