Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting all of the properties (Including the hidden ones) of 0 (The root object)

Tags:

matlab

It seems that the root object, a.k.a 0 has hidden properties in Matlab. For example, DefaultTextInterpreter is one of them:

 x = get(0,'DefaultTextInterpreter');

When I use

 get(0)

I get a long list, which does not include DefaultTextInterpreter.


Even setting undocumented properties to be visible by

 set(0,'HideUndocumented','off');

does not seem to help.


How can I find all of the properties of the root object, including DefaultTextInterpreter?

like image 916
Andrey Rubshtein Avatar asked Feb 13 '12 21:02

Andrey Rubshtein


People also ask

What is the root object in MATLAB?

A short summary: The root object is the parent object of all figures. Some of its properties belong to the Matlab session, as e.g. the CurrentFigure. Some concern the current computer setup as the ScreenSize or the PointerLocation.

How to get the value of each property of an object?

The value of each property can be accessed using the keys with an array notation of the object. Therefore, the keys are not required to be known beforehand to get all the property values.

How to get a list of a type’s properties?

You can get a list of a type’s properties using reflection, like this: Note: If you have an object, use movie.GetType ().GetProperties () instead.

How to show all available properties on an object in Python?

The three approaches above should make it easy to show all of the available properties on an object in Python. using dir () is probably the most useful as it is the easiest to read.


1 Answers

Default properties are not hidden nor undocumented - they are available for all standard Handle Graphics properties by simply prefixing 'Default' to the property name, together with the object type ('Line', 'Axes' etc.). This is explained in the official documentation.

In fact, this mechanism also works for hidden/undocumented properties, as shown for the LineSmoothing property.

To see all the supported default properties, do as follows:

>> get(0,'Default')
ans = 
          defaultFigurePosition: [440 378 560 420]
               defaultTextColor: [0 0 0]
              defaultAxesXColor: [0 0 0]
              defaultAxesYColor: [0 0 0]
              defaultAxesZColor: [0 0 0]
          defaultPatchFaceColor: [0 0 0]
          defaultPatchEdgeColor: [0 0 0]
               defaultLineColor: [0 0 0]
    defaultFigureInvertHardcopy: 'on'
             defaultFigureColor: [0.8 0.8 0.8]
               defaultAxesColor: [1 1 1]
          defaultAxesColorOrder: [7x3 double]
          defaultFigureColormap: [64x3 double]
        defaultSurfaceEdgeColor: [0 0 0]
         defaultFigurePaperType: 'A4'
        defaultFigurePaperUnits: 'centimeters'
         defaultFigurePaperSize: [20.98404194812 29.67743169791]

Note that this does not return the undocumented defaults. You can always get the undocumented defaults directly:

>> get(0,'DefaultLineLineSmoothing')
ans =
off


Since I can't help myself :-), here's a bit of now-really-undocumented knowledge, which does not answer the OP question but it somehow related. Readers who are only interested in the original question or in purely-documented/supported stuff can safely skip this part:
>> p = findprop(handle(gcf),'pos')
p =
    schema.prop

>> p.get
            Name: 'Position'
     Description: ''
        DataType: 'figurePositionType'
    FactoryValue: [100 100 660 520]
     AccessFlags: [1x1 struct]
         Visible: 'on'
     GetFunction: []
     SetFunction: []

In this simple snippet, note that the default (FactoryValue) for the position property of the UDD hg.Figure class is different than the HG default that is returned by the root's DefaultFigurePosition property. More information on UDD properties can be found here.

Addendum 2013-02-13: I've just posted a detailed article explaining how Matlab's Default and Factory property values work, how they relate to each other, and how they can be accessed.

like image 188
Yair Altman Avatar answered Nov 14 '22 23:11

Yair Altman