I have a simple script to reproduce the issue:
f = figure();ax = axes(f);plot(rand(5));ax.ButtonDownFcn = @(hObject,eventdata)disp('Hi');axes(ax);plot(sin(1:0.01:25.99));
Seems the second plot() created a new axes, and callback wiring is lost. If only running the first four lines of code, callback is run fine with printing 'Hi' on the MATLAB Command Window, but if running the whole script, no callback will be run.
Best Answer