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!