buttondown not working with plotyy
Ältere Kommentare anzeigen
In my GUI, I previously had several small axes, each of which was copied to a larger axes when the user clicked a specific small axes using buttondown. main parts of code:
function ButtonDown(hObject, eventdata, handles);
handles = guidata(hObject);
theaxes = ancestor(hObject,'axes');
if theaxes == handles.axes2;
plot....
However, I needed to use plotyy to create secondary y axes for some of the smaller plots. Doing this has disabled my buttondown function for said plots. How do I fix this? I have tried to manipulate 'hittest' property and 'clickableparts' to no avail.
Thanks
1 Kommentar
dpb
am 8 Okt. 2015
I've never done anything with GUIs or callbacks but I'd guess your issue is that there are two axes handles generated by plotyy and you're not getting the callback assigned to each of them analogously as to your individual axes cases.
Antworten (1)
David
am 28 Mär. 2018
How are you setting the 'ButtonDownFcn' value for plotyy? It cannot be done in the function call itself, but it can be done by assigning the 'ButtonDownFcn' property to each axis directly:
[ax, h1, h2] = plotyy(xdata1, ydata1, xdata2, ydata2);
ax(1).ButtonDownFcn=@CallbackFunction;
Note: MATLAB only recognizes one callback function for the axes. If you assign a callback function to both axes, (i.e. ax(1) and ax(2)) only the function for ax(1) will be used.
Kategorien
Mehr zu Two y-axis finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!