- Undocumented Matlab - https://undocumentedmatlab.com -

Displaying hidden handle properties

Posted By Yair Altman On 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:


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 =

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” [1] 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.

Categories: Hidden property, High risk of breaking in future versions

15 Comments (Open | Close)

15 Comments To "Displaying hidden handle properties"

#1 Comment By Steve Eddins On May 6, 2009 @ 04:40

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

#2 Comment By Yair Altman On May 6, 2009 @ 10:22

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 🙂

#3 Comment By Matt Whitaker On May 15, 2009 @ 15:45

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.

t = text('Parent',gca,'String','Some Text');
hold 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.


#4 Comment By Jason McMains On May 29, 2009 @ 05:16

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?


#5 Comment By Yair Altman On May 30, 2009 @ 11:07

@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.

#6 Comment By Jason McMains On June 9, 2009 @ 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:)

#7 Comment By Jason McMains On June 22, 2009 @ 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.

#8 Comment By Cris On September 28, 2009 @ 02:40

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’.

#9 Pingback By Customizing print setup | Undocumented Matlab On November 25, 2009 @ 13:27

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

#10 Pingback By Axes LooseInset property | Undocumented Matlab On March 24, 2010 @ 11:18

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

#11 Pingback By Matlab’s HG2 mechanism | Undocumented Matlab On May 7, 2010 @ 03:53

[…] “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’: >> […]

#12 Pingback By FIG files format | Undocumented Matlab On December 22, 2010 @ 13:01

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

#13 Pingback By getundoc – get undocumented object properties | Undocumented Matlab On September 21, 2011 @ 12:02

[…] 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. […]

#14 Comment By Ramiro Massol On June 23, 2014 @ 13:34

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).

#15 Comment By Cris Luengo On July 26, 2021 @ 19:19

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).

Article printed from Undocumented Matlab: https://undocumentedmatlab.com

URL to article: https://undocumentedmatlab.com/articles/displaying-hidden-handle-properties

URLs in this post:

[1] “Hidden property”: http://undocumentedmatlab.com/blog/category/Hidden-property/

[2] Performance: accessing handle properties : https://undocumentedmatlab.com/articles/performance-accessing-handle-properties

[3] Adding custom properties to GUI objects : https://undocumentedmatlab.com/articles/adding-custom-properties-to-gui-objects

[4] Handle Graphics Behavior : https://undocumentedmatlab.com/articles/handle-graphics-behavior

[5] Accessing hidden HG2 plot functionality : https://undocumentedmatlab.com/articles/hidden-hg2-plot-functionality

[6] Displaying animated GIFs : https://undocumentedmatlab.com/articles/displaying-animated-gifs

[7] UDD Properties : https://undocumentedmatlab.com/articles/udd-properties

[8] : http://www.mathworks.com/access/helpdesk/help/techdoc/ref/figure_props.html

Copyright © Yair Altman - Undocumented Matlab. All rights reserved.