How do I listen for when new axes are added to a figure?
Mostra commenti meno recenti
I would like to know when new axes are added to a figure. The axes will always have the figure as a parent. I have tried using the ChildAdded event listener, but this does not trigger when, for example, the subplot function creates a new set of axes.
2 Commenti
Steven Lord
il 6 Giu 2019
How would you use this information if it was available? What's your use case? Knowing what your ultimate goal is may allow us to offer a better solution than trying to listen for new axes being added.
Matthew
il 6 Giu 2019
Risposta accettata
Più risposte (1)
Daniel Dolan
il 28 Ott 2020
Matthew,
I've been looking for a similar feature that keeps a particular axes on top of everything else. The ChildAdded listener triggers on menu, panel, and uicontrol additions, but not axes creation.
The best I have come up with is to monitor the figure's CurrentAxes property.
L=listener(gcf,'CurrentAxes','PostSet',@(~,~) disp('current axes changed'))
This appears to work for axes and subplot calls.
Dan
Categorie
Scopri di più su Creating, Deleting, and Querying Graphics Objects in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!