How to respond to update of axis data?

2 views (last 30 days)
I need to set a callback for when data in axis is updated. Is there a way to do this? i.e is their a way to be notified when a figure/axis/line data changes.

Accepted Answer

Eric Delgado
Eric Delgado on 6 Oct 2022
Edited: Eric Delgado on 6 Oct 2022
Hey @bethel o, yeah, it's possible. "YData" is not a property of figure or axes, ok?
fig = figure;
ax1 = axes(fig);
h = plot(ax1, randn(1001,1));
addlistener(h, 'YData', 'PostSet', @(~,~)disp("YData changed!"));
% Changing data...
h.YData(1) = 2*h.YData(1);
% Answer:
% "YData changed!"
  1 Comment
bethel o
bethel o on 7 Oct 2022
How do you acquired this kind of Jedi skills?

Sign in to comment.

More Answers (0)


Find more on Interactive Control and Callbacks in Help Center and File Exchange




Community Treasure Hunt

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

Start Hunting!

Translated by