MATLAB: After plotting on axes the ButtonDownFcn doesn’t work

axesbuttondownfcnguiMATLABplot

Hi,
I have a GUI with 3 axes. Before plotting the data the three functions axesX_ButtonDownFcn(…) work, but when I plot the data they don't work anymore.
I have tried this but doesn't work:
axes(handles.plot1);
handles.cursorPlot1 = plot(handles.simulation_data_temp(8,:), 'Parent',...
handles.axes1, 'HitTest', 'off', 'ButtonDownFcn', '');
What I am doing wrong?
Thanks.

Best Answer

>> AxesH = axes('ButtonDownFcn', 'disp(''Axes click!'')');
Axes click!
Axes click!
>> plot(1:10) % Now clicking does nothing....
No more 'Axes click!', but now try this:
>> clear all,close all
>> AxesH = axes('ButtonDownFcn', 'disp(''Axes click!'')');
Axes click!
>> hold all
>> plot(1:10)
Axes click!
Axes click!
Basically, when you plot on an axes that has the nextplot property set to replace, all callbacks, etc are reset in that call.