get - Query graphics object properties - MATLAB (original) (raw)
Query graphics object properties
Syntax
Description
get([h](#mw%5Fd6b892eb-17a1-462b-9b14-c55ec42d06b0))
displays the properties and property values for the specified graphics object h
in the Command Window.h
must be a single object. If h
is empty ([ ]),get
does nothing and does not return an error or warning.
[s](#mw%5Fd08ce993-b385-486f-a02e-be0b1445e2eb) = get([h](#mw%5Fd6b892eb-17a1-462b-9b14-c55ec42d06b0))
returns a structure containing all properties and property values for the specified graphics objecth
. If h
is a vector of objects, thenget
returns the properties and values for all the objects inh
. If h
is empty ([ ]), get
does nothing and does not return an error or warning.
[v](#mw%5F1d000ca6-a220-479c-9e0e-40282309e735) = get([h](#mw%5Fd6b892eb-17a1-462b-9b14-c55ec42d06b0),[propertyNames](#mw%5Fe180625d-1ad8-43d1-a079-0dc6102a3584))
returns the values of the specified properties for the specified graphics objecth
.
- If
h
is a single object andpropertyNames
is a string or character vector that specifies one property,get
returns the value of the specified property. Ifh
is a single object andpropertyNames
is a cell array that specifies one or more properties,get
returns a1
-by-n cell array containing the values of the specified properties, where n is the number of properties inpropertyNames
. - If
h
is a vector of objects,get
returns an _m_-by-n cell array containing the values of the specified properties, where m is the number of elements inh
and n is the number of properties contained inpropertyNames
.
[s](#mw%5Fd08ce993-b385-486f-a02e-be0b1445e2eb) = get([h](#mw%5Fd6b892eb-17a1-462b-9b14-c55ec42d06b0),"default")
returns a structure containing all default property values defined for the specified object.
[s](#mw%5Fd08ce993-b385-486f-a02e-be0b1445e2eb) = get(groot,"factory")
returns a structure containing the factory-defined values of all user-settable properties for the graphics root object, groot.
[v](#mw%5F1d000ca6-a220-479c-9e0e-40282309e735) = get([h](#mw%5Fd6b892eb-17a1-462b-9b14-c55ec42d06b0),[defaultTypeProperty](#mw%5Fa8842b90-c552-423e-a379-353aae80cc74))
returns the default value of the specified property and object type for the specified graphics object h
. defaultTypeProperty
is the worddefault
concatenated with the object type (for example,Figure
) and the property name (for example, Color
) in quotes. For example, v = get(groot,"defaultFigureColor")
returns the default value of the Color
property of Figure
objects for the graphics root object, groot
.
[v](#mw%5F1d000ca6-a220-479c-9e0e-40282309e735) = get(groot,[factoryTypeProperty](#mw%5Faeb9a5f7-3cf9-4589-aba0-9d2b822b9ea9))
returns the factory-defined value of the specified property and object type for the graphics root object, groot
. factoryTypeProperty
is the word factory
concatenated with the object type (for example,Figure
) and the property name (for example, Color
) in quotes. For example, v = get(groot,"factoryFigureColor")
returns the factory-defined value of the Color
property of Figure
objects.
Examples
Create a line plot and return the Line
object as p
. List all of the properties and current values of the object.
AffectAutoLimits: on
AlignVertexCenters: off
Annotation: [1×1 matlab.graphics.eventdata.Annotation]
BeingDeleted: off
BusyAction: 'queue'
ButtonDownFcn: ''
Children: [0×0 GraphicsPlaceholder]
Clipping: on
Color: [0.0660 0.4430 0.7450]
ColorMode: 'auto'
ContextMenu: [0×0 GraphicsPlaceholder]
CreateFcn: ''
DataTipTemplate: [1×1 matlab.graphics.datatip.DataTipTemplate]
DeleteFcn: ''
DisplayName: ''
HandleVisibility: 'on'
HitTest: on
Interruptible: on
LineJoin: 'round'
LineStyle: '-'
LineStyleMode: 'auto'
LineWidth: 0.5000
Marker: 'none'
MarkerEdgeColor: 'auto'
MarkerFaceColor: 'none'
MarkerIndices: [1 2 3 4 5 6 7 8 9 10]
MarkerMode: 'auto'
MarkerSize: 6
Parent: [1×1 Axes]
PickableParts: 'visible'
Selected: off
SelectionHighlight: on
SeriesIndex: 1
SourceTable: [0×0 table]
Tag: ''
Type: 'line'
UserData: []
Visible: on
XData: [1 2 3 4 5 6 7 8 9 10]
XDataMode: 'auto'
XDataSource: ''
XVariable: ''
YData: [1 2 3 4 5 6 7 8 9 10]
YDataMode: 'manual'
YDataSource: ''
YVariable: ''
ZData: [1×0 double]
ZDataMode: 'auto'
ZDataSource: ''
ZVariable: ''
Create a line plot and return the Line
object as p
. Get the current value of the LineWidth
property.
Create a figure with the title My App
. Get the current values of the Name
, Position
, and Color
properties of the figure.
fig = uifigure("Name","My App");
props = {"Name","Position","Color"}; get(fig,props)
ans=1×3 cell array {'My App'} {[348 367 583 437]} {[0.9608 0.9608 0.9608]}
Get the default values defined on the root for all graphics objects.
ans = struct with fields: defaultFigurePosition: [167 243 560 337.1852] defaultFigurePaperPositionMode: 'auto' defaultFigureVisible: off defaultFigureToolBar: 'none' defaultFigureMenuBar: 'none' defaultFigureWindowStyle: 'normal'
Create a red line plot and return the Line
object as p
.
p = plot(1:10,"Color","red");
Get the current and default values of the Color
property defined for p
.
get(p,"defaultLineColor")
ans = 1×3
0.1294 0.1294 0.1294
Get the factory-defined value of the MarkerSize
property defined on the root for all Line
objects.
get(groot,"factoryLineMarkerSize")
Input Arguments
Graphics objects, specified as a single object or a vector of objects.
Property names, specified as a string scalar, character vector, or cell array.
Default property name, specified as a string scalar or character vector.defaultTypeProperty
is the word default
concatenated with the object type (for example, Figure
) and the property name (for example, Color
) in quotes.
Example: get(groot,"defaultFigureColor")
Factory property name, specified as a string scalar or character vector.factoryTypeProperty
is the word factory
concatenated with the object type (for example, Figure
) and the property name (for example, Color
) in quotes.
Example: get(groot,"factoryFigureColor")
Output Arguments
Property names and their values, returned as a structure. In the structure, the field names are the object property names, and the field values are the corresponding property values.
Property values, returned as a single value of any data type or a cell array.
Version History
Introduced before R2006a