MATLAB Answers

Observe graphics object added to the axes

6 views (last 30 days)
Zoltán Csáti
Zoltán Csáti on 30 Oct 2017
Commented: Zoltán Csáti on 13 May 2020
I have an axes object which contains several child objects (lines, patches, etc.). I have a function which sets the callback function for these objects. What I want is that whenever the user adds another object to the axes, an event is activated and sets the callback for the newly added object. My idea was to look when the number of the children of axes grow as it indicates a new object. Unfortunately, axes.Children is not a SetObservable property, so listeners cannot be attached to the axes object. Any ideas how to solve this problem?

Answers (1)

Roman Müller-Hainbach
Roman Müller-Hainbach on 2 Nov 2017
Maybe the 'LegendableObjectsUpdated' event could be used for your purposes. I retrieved this from
Zoltán Csáti
Zoltán Csáti on 13 May 2020
Thank you. I will try it out once I have access to MATLAB. On this computer, I don't have a license, and on the other computer, I have R2015b. The poor backward compatibility in MATLAB is a pity...

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!