uifigure alternatives for gcf, gcbf, gco, gcbo, gca, and any other legacy figure based functions

34 views (last 30 days)
Hello, I was wondering if any alternatives that work with the new uifigure windows are being developed for gcf, gcbf, gco, gcbo, gca, and any other legacy functions that used to work with legacy figures (guihandles, for example).

Accepted Answer

Walter Roberson
Walter Roberson on 2 Jun 2023
I used to think that those functions simplify didn't apply to uifigure and children. However someone indicated that the real issue is that by default handle visibility is off for those, and that if you turn handle visibility on that the functions will work. I have not tested this.
  7 Comments
dpb
dpb on 12 Nov 2025 at 20:53
Edited: dpb on 14 Nov 2025 at 18:57
Excepting for the uifigure itself, the other objects will still default to 'HandleVisibility','on' so they wouldn't be obscured, anyways. However, it does appear that the builtins are restricted to finding only children of handle-visible figures so the results will depend on the uifigure handle being visible at the time they are calleed.
If the visibility is on, then it appears that would be the case; however, that also leads to the possibility of the problem @Walter Roberson notes above, particularly acute if there's the possibility of user interaction thru a gui that can change focus.
The use of setting the uifigure visibility should probably be restricted to as minimal section of code as is possible and then reset back off in order to avoid that. Locate and save the handle of interest immediately and then use it as the target if calling any of the others. gca on its own will still get a current normal axes if one exists, but if one doesn't, it will create one in a new normal figure, not return the one that may be in the uifigure you just found when not visible.
Stephen23
Stephen23 on 13 Nov 2025 at 13:48
If you want to write repeatable robust code then use explicit object handles.
If you want code that is fragile then use GCF, GCBF, GCO, GCBO, CGA, etc.

Sign in to comment.

More Answers (0)

Categories

Find more on Graphics Object Programming in Help Center and File Exchange

Products


Release

R2023a

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!