Undocumented Matlab
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT
  • SERVICES
    • Consulting
    • Development
    • Training
    • Gallery
    • Testimonials
  • PRODUCTS
    • IQML: IQFeed-Matlab connector
    • IB-Matlab: InteractiveBrokers-Matlab connector
    • EODML: EODHistoricalData-Matlab connector
    • Webinars
  • BOOKS
    • Secrets of MATLAB-Java Programming
    • Accelerating MATLAB Performance
    • MATLAB Succinctly
  • ARTICLES
  • ABOUT
    • Policies
  • CONTACT

Displaying hidden handle properties

May 5, 2009 15 Comments

Matlab Handle Graphics (HG) is a great way to manipulate GUI objects. HG handles often have some undocumented hidden properties. One pretty well-known example is the JavaFrame property of the figure handle, which enables access to the GUI’s underlying Java peer object. We can use hidden properties just like any other handle property, using the built-in get and set functions.
But how can we know about these properties? Here are two methods to do so. Like the hidden properties, these two methods are themselves undocumented…
1. use the desktop’s hidden HideUndocumented property:

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

From now on, when displaying handle properties using get and set you’ll see the hidden properties.
Note that some of the properties might display a warning indication:

>> get(gcf)
	Alphamap = [ (1 by 64) double array]
	BackingStore = on
	CloseRequestFcn = closereq
	Color = [0.8 0.8 0.8]
	Colormap = [ (64 by 3) double array]
	CurrentAxes = []
	CurrentCharacter =
	CurrentKey =
	CurrentModifier = [ (1 by 0) cell array]
	CurrentObject = []
	CurrentPoint = [0 0]
	DithermapWarning: figure Dithermap is no longer useful
 with TrueColor displays, and will be removed in a future release.
 = [ (64 by 3) double array]
        ...

2. Access the properties’ definition in the handle’s class definition:

>> ch = classhandle(handle(gcf));
>> props = get(ch,'Properties');
>> propsVisibility = get(props,'Visible')';
>> hiddenProps = props(strcmp(propsVisibility,'off'));
>> sort(get(hiddenProps,'Name'))
ans =
    'ALimInclude'
    'ActivePositionProperty'
    'ApplicationData'
    'BackingStore'
    'Behavior'
    'CLimInclude'
    'CurrentKey'
    'CurrentModifier'
    'Dithermap'
    'DithermapMode'
    'ExportTemplate'
    'HelpFcn'
    'HelpTopicKey'
    'HelpTopicMap'
    'IncludeRenderer'
    'JavaFrame'
    'OuterPosition'
    'PixelBounds'
    'PrintTemplate'
    'Serializable'
    'ShareColors'
    'UseHG2'
    'WaitStatus'
    'XLimInclude'
    'YLimInclude'
    'ZLimInclude'

Different HG handles have different hidden properties. Not all these properties are useful. For example, I have found the PixelBounds property to be problematic – (it sometimes reports incorrect values!). Other properties (like Dithermap or ShareColors) are deprecated and display a warning wherever they are accessed.
But every so often we find a hidden property that can be of some actual benefit. Let’s take the figure handle’s OuterPosition property for example. It provides the figure’s external position values, including the space used by the window frame, toolbars etc., whereas the regular documented Position property only reports the internal bounds:

>> get(gcf,'pos')
ans =
   232   246   560   420
>> get(gcf,'outer')
ans =
   228   242   568   502

In future posts I will sometimes use such hidden properties. You can find the latest list by looking at this blog’s “Hidden property” category page.
Note: Like the rest of Matlab’s undocumented items, all hidden properties are undocumented, unsupported and may well change in future Matlab releases so use them with care.
Did you find any useful hidden property? If so, then please leave your finding in the comments section below.

Related posts:

  1. Performance: accessing handle properties – Handle object property access (get/set) performance can be significantly improved using dot-notation. ...
  2. Adding custom properties to GUI objects – It is very easy to add custom user-defined properties and methods to GUI handles and Java references in Matlab. ...
  3. Handle Graphics Behavior – HG behaviors are an important aspect of Matlab graphics that enable custom control of handle functionality. ...
  4. Accessing hidden HG2 plot functionality – In HG2, some of the plot functionality is hidden in undocumented properties. ...
  5. Displaying animated GIFs – It is possible to easily display animated images in Matlab figure windows. ...
  6. UDD Properties – UDD provides a very convenient way to add customizable properties to existing Matlab object handles...
Hidden property JavaFrame OuterPosition PixelBounds schema.class schema.prop
Print Print
« Previous
Next »
15 Responses
  1. Steve Eddins May 6, 2009 at 04:40 Reply

    Hi Yair. The OuterPosition property of figures is documented, although I see that get(gcf) doesn’t display it by default. I don’t know the reason for the discrepancy.

    • Yair Altman May 6, 2009 at 10:22 Reply

      Thanks Steve – that’s a nice catch that I probably would never have seen…
      Hidden but documented: that’s a new one – I learn something new each day 🙂

  2. Matt Whitaker May 15, 2009 at 15:45 Reply

    One nice little property of axes (using R2009a) is ‘ContentsVisible’. Seems to be a nice way of toggling off the visibility contents of an axes while you update it.


    plot(1:5)
    t = text('Parent',gca,'String','Some Text');
    set(gca,'ContentsVisible','off')
    hold on
    plot(5:-1:0)
    set(t,'Position',[3,3])
    set(gca,'ContentsVisible','on')

    Sure it can be done numerous other ways but one scenario I have encountered is having a bunch of objects in an axes that have a mixture of visible states. You want to hide the contents while some update goes on. You have to find all the visible children, turn them off, keep that list in memory to only restore the visible stuff. The above seems much cleaner. I have not run into any gotchas yet.

    Thanks for the great website. You’ve been a great help over the last couple of years.

    Matt

  3. Jason McMains May 29, 2009 at 05:16 Reply

    Yair, I’ve been looking around your getjframe program to get more of these “hidden handle properties.” This adds a lot of great extra functionality! Thanks for that! My question is that for some reason if I set the figure as invisible, all of those hidden callbacks, ie ‘WindowStateChangedCallback’ stop running. Any ideas?

    Thanks
    Jason

    • Yair Altman May 30, 2009 at 11:07 Reply

      @Jason – the Java properties & callbacks are only relevant for visible figure frames. After all, how can you minimize/maximize a hidden frame??? Still, you can access these properties if you simply keep the figure visible and just set its position to somewhere off-screen (say, x=y=9999). The figure will remain visible although effectively hidden from view; it will remain displayed in the taskbar for this reason.

      • Jason McMains June 9, 2009 at 04:09

        @Yair Unfortunately part of the code I’m working on is to “minimize to the system tray” like I can do in outlook and some other programs, which involves setting the visibility off to remove it from the task bar. I’ve gotten it to work some of the time, but certain sequences of commands still mess it up. The system tray icon is a great extra resource by the way, thanks for that little piece of wisdom:)

      • Jason McMains June 22, 2009 at 11:26

        @Yair, I finally think I figured out the problem, but its just a simple logic fix, every time I set the figure back to visible, I get the javaframe, and include that as the callback argument, and remove the old javaframe.

  4. Cris September 28, 2009 at 02:40 Reply

    Hey Yair, nice blog!

    The ‘ApplicationData’ property might not be documented, but the GETAPPDATA and SETAPPDATA access functions are. It’s just a better structured implementation of the ‘UserData’ property. I still prefer using ‘UserData’ just because it’s more flexible. You get an error if you try to write anything that is not a stuct into ‘ApplicationData’.

  5. Customizing print setup | Undocumented Matlab November 25, 2009 at 13:27 Reply

    […] the figure-specific print setup is stored in another hidden property, PrintTemplate […]

  6. Axes LooseInset property | Undocumented Matlab March 24, 2010 at 11:18 Reply

    […] another undocumented property of Matlab axes, ContentsVisible, was described by Matt Whittaker in a comment on my original article that introduced undocumented properties […]

  7. Matlab’s HG2 mechanism | Undocumented Matlab May 7, 2010 at 03:53 Reply

    […] “Handle Graphics 2nd generation”, was already reported in the past as an undocumented hidden figure property (UseHG2). In normal Matlab usage, this boolean property is ‘off’: >> […]

  8. FIG files format | Undocumented Matlab December 22, 2010 at 13:01 Reply

    […] we can see hidden/undocumented properties of the stored objects (for example, the lineseries’ XDataJitter and ObeyXDataMode properties) […]

  9. getundoc – get undocumented object properties | Undocumented Matlab September 21, 2011 at 12:02 Reply

    […] Which is where today’s post can help, by showing you how to list these hidden properties. I wrote about this a couple of years ago, and today’s article will expand on that original post. […]

  10. Ramiro Massol June 23, 2014 at 13:34 Reply

    hi Yair
    Just to let you know new bad news about Matlab. I was testing the pre-release of Matlab 2014b. The “set(0,’HideUndocumented’,’off’);” does not work anymore, which may mean that all the undocumented properties and functions relying on them may not work anymore (for instance, uicomponent does not work).
    best

  11. Cris Luengo July 26, 2021 at 19:19 Reply

    Neither set(0,’HideUndocumented’,’off’) nor classhandle(…) work any more (testing on R2021a). However, it is possible to convert a HG2 handle to a struct, and see all the hidden properties: struct(gcf).

Leave a Reply
HTML tags such as <b> or <i> are accepted.
Wrap code fragments inside <pre lang="matlab"> tags, like this:
<pre lang="matlab">
a = magic(3);
disp(sum(a))
</pre>
I reserve the right to edit/delete comments (read the site policies).
Not all comments will be answered. You can always email me (altmany at gmail) for private consulting.

Click here to cancel reply.

Useful links
  •  Email Yair Altman
  •  Subscribe to new posts (feed)
  •  Subscribe to new posts (reader)
  •  Subscribe to comments (feed)
 
Accelerating MATLAB Performance book
Recent Posts

Speeding-up builtin Matlab functions – part 3

Improving graphics interactivity

Interesting Matlab puzzle – analysis

Interesting Matlab puzzle

Undocumented plot marker types

Matlab toolstrip – part 9 (popup figures)

Matlab toolstrip – part 8 (galleries)

Matlab toolstrip – part 7 (selection controls)

Matlab toolstrip – part 6 (complex controls)

Matlab toolstrip – part 5 (icons)

Matlab toolstrip – part 4 (control customization)

Reverting axes controls in figure toolbar

Matlab toolstrip – part 3 (basic customization)

Matlab toolstrip – part 2 (ToolGroup App)

Matlab toolstrip – part 1

Categories
  • Desktop (45)
  • Figure window (59)
  • Guest bloggers (65)
  • GUI (165)
  • Handle graphics (84)
  • Hidden property (42)
  • Icons (15)
  • Java (174)
  • Listeners (22)
  • Memory (16)
  • Mex (13)
  • Presumed future risk (394)
    • High risk of breaking in future versions (100)
    • Low risk of breaking in future versions (160)
    • Medium risk of breaking in future versions (136)
  • Public presentation (6)
  • Semi-documented feature (10)
  • Semi-documented function (35)
  • Stock Matlab function (140)
  • Toolbox (10)
  • UI controls (52)
  • Uncategorized (13)
  • Undocumented feature (217)
  • Undocumented function (37)
Tags
AppDesigner (9) Callbacks (31) Compiler (10) Desktop (38) Donn Shull (10) Editor (8) Figure (19) FindJObj (27) GUI (141) GUIDE (8) Handle graphics (78) HG2 (34) Hidden property (51) HTML (26) Icons (9) Internal component (39) Java (178) JavaFrame (20) JIDE (19) JMI (8) Listener (17) Malcolm Lidierth (8) MCOS (11) Memory (13) Menubar (9) Mex (14) Optical illusion (11) Performance (78) Profiler (9) Pure Matlab (187) schema (7) schema.class (8) schema.prop (18) Semi-documented feature (6) Semi-documented function (33) Toolbar (14) Toolstrip (13) uicontrol (37) uifigure (8) UIInspect (12) uitable (6) uitools (20) Undocumented feature (187) Undocumented function (37) Undocumented property (20)
Recent Comments
Contact us
Captcha image for Custom Contact Forms plugin. You must type the numbers shown in the image
Undocumented Matlab © 2009 - Yair Altman
This website and Octahedron Ltd. are not affiliated with The MathWorks Inc.; MATLAB® is a registered trademark of The MathWorks Inc.
Scroll to top