buttondown not working with plotyy
显示 更早的评论
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 个评论
dpb
2015-10-8
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.
回答(1 个)
David
2018-3-28
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.
类别
在 帮助中心 和 File Exchange 中查找有关 Two y-axis 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!