Main Content

get

Query graphics object properties

    Description

    example

    get(h) 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 = get(h) returns a structure containing all properties and property values for the specified graphics object h. If h is a vector of objects, then get returns the properties and values for all the objects in h. If h is empty ([ ]), get does nothing and does not return an error or warning.

    example

    v = get(h,propertyNames) returns the values of the specified properties for the specified graphics object h.

    • If h is a single object and propertyNames is a string or character vector that specifies one property, get returns the value of the specified property. If h is a single object and propertyNames is a cell array that specifies one or more properties, get returns a 1-by-n cell array containing the values of the specified properties, where n is the number of properties in propertyNames.

    • 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 in h and n is the number of properties contained in propertyNames.

    example

    s = get(h,"default") returns a structure containing all default property values defined for the specified object.

    s = get(groot,"factory") returns a structure containing the factory-defined values of all user-settable properties for the graphics root object, groot.

    example

    v = get(h,defaultTypeProperty) returns the default value of the specified property and object type for the specified graphics object h. defaultTypeProperty is the word default 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.

    example

    v = get(groot,factoryTypeProperty) 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

    collapse all

    Create a line plot and return the Line object as p. List all of the properties and current values of the object.

    p = plot(1:10);

    Figure contains an axes object. The axes object contains an object of type line.

    get(p)
          AffectAutoLimits: on
        AlignVertexCenters: off
                Annotation: [1x1 matlab.graphics.eventdata.Annotation]
              BeingDeleted: off
                BusyAction: 'queue'
             ButtonDownFcn: ''
                  Children: [0x0 GraphicsPlaceholder]
                  Clipping: on
                     Color: [0 0.4470 0.7410]
                 ColorMode: 'auto'
               ContextMenu: [0x0 GraphicsPlaceholder]
                 CreateFcn: ''
           DataTipTemplate: [1x1 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: [1x1 Axes]
             PickableParts: 'visible'
                  Selected: off
        SelectionHighlight: on
               SeriesIndex: 1
               SourceTable: [0x0 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: [1x0 double]
                 ZDataMode: 'auto'
               ZDataSource: ''
                 ZVariable: ''
    

    Create a line plot and return the Line object as p. Get the current value of the LineWidth property.

    p = plot(1:10);

    Figure contains an axes object. The axes object contains an object of type line.

    get(p,"LineWidth")
    ans = 0.5000
    

    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 376 583 437]}    {[0.9400 0.9400 0.9400]}
    
    

    Get the default values defined on the root for all graphics objects.

    get(groot,"default")
    ans = struct with fields:
                 defaultFigurePosition: [348 376 583 437]
        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");

    Figure contains an axes object. The axes object contains an object of type line.

    Get the current and default values of the Color property defined for p.

    get(p,"Color")
    ans = 1×3
    
         1     0     0
    
    
    get(p,"defaultLineColor")
    ans = 1×3
    
         0     0     0
    
    

    Get the factory-defined value of the MarkerSize property defined on the root for all Line objects.

    get(groot,"factoryLineMarkerSize")
    ans = 6
    

    Input Arguments

    collapse all

    Graphics objects, specified as a single object or a vector of objects.

    Note

    Do not use the get function on Java® objects as it will cause a memory leak. For more information, see Access Public and Private Data.

    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

    collapse all

    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