Skip to Main Content Skip to Search
Home |   Select Country  Choose Country  |  Contact Us  |  Cart Store 
Create Account | Log In
Products & Services Solutions Academia Support User Community Company
spacer spacer spacer spacer spacer spacer

Technical Solutions

Why is the 'ButtonDownFcn' property of an axes in a GUI not called after I plot a figure in MATLAB 7.3 (R2006b) ?


Date Last Modified: Friday, June 26, 2009
Solution ID:   1-3K8R2L
Product:   MATLAB
Reported in Release:   R2006b
Platform:   All Platforms
Operating System:   All OS
 

Subject:

Why is the 'ButtonDownFcn' property of an axes in a GUI not called after I plot a figure in MATLAB 7.3 (R2006b) ?

Problem Description:

The 'ButtonDownFcn' property of an axes is defined in the property inspector during the GUI building process.

However, this function is not being called when I run my GUI.

Solution:

High-level plotting functions, by default, clear the axes properties (except the 'position' and the 'units' property).

To prevent calls to PLOT, BAR, etc. from replacing the buttondownfcn, set the 'NextPlot' property of the axes to 'replacechildren' instead of the default 'replace'. This will clear the axes contents and plot the new data without replacing the axes object itself.

If you want to plot data over your existing data, then set the 'NextPlot' property of the axes to 'Add'.

An alternative workaround is to assign 'ButtoDownFcn' for the axes again after calling the plot.

axes(axes_handle);
bar(n,m);
set(axes_handle, 'ButtonDownFcn', {@FcnName, arg1, arg2});

Please provide feedback to help us improve this Solution
Contact support
E-mail this page
Print this page