determining number of axes on a figure
Afficher commentaires plus anciens
how can I determine the number of axes that a figure has?
using get(figure,'Children') works but also gives data on non-axis children, which I don't want
Réponses (2)
Walter Roberson
le 10 Avr 2012
Do you only want axes that are immediate children, or do you want all axes, even those that might be several objects down (such as within uipanel) ? And how about if the handles are hidden, do you want them returned or not?
Immediate children only:
findobj( get(gcf,'Children'), '-depth', 1, 'type', 'axes')
All children (including hidden) at all levels:
findall(gcf, 'type', 'axes')
5 commentaires
Daniel Shub
le 10 Avr 2012
I much better answer than mine. A little text goes a long way.
Art
le 10 Avr 2012
Daniel Shub
le 10 Avr 2012
Both legends and colorbars are axes. There maybe other things that show up as axes. You can eliminate them on a case by case basis ...
findobj(gcf, 'type', 'axes', '-not', 'tag', 'legend', '-not', 'tag', 'Colorbar')
Art
le 11 Avr 2012
Massimo Ciacci
le 16 Nov 2021
Awesome tip, didn't know about '-depth'. Works a charm.
Daniel Shub
le 10 Avr 2012
findobj(gcf, 'type', 'axes')
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!