How do I add ActionPostCallback to GUI axes
조회 수: 11 (최근 30일)
이전 댓글 표시
Using Matlab 2016b, I have used GUIDE to create a gui containing axes. I want to be able to control the XTick and XTickLabels shown in the plot. Therefore I try to add a callback to the zoom and pan event. During the axes create function I try to add a ActionPostCallback for zoom and pan. This works for the zoom part but it fails in the pan(hObject) part, since hObject is not a figure handle as far as I understand. How can I add a callback to the pan event?
function axes1_CreateFcn(hObject, eventdata, handles)
% hObject handle to axes1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns called
% Hint: place code in OpeningFcn to populate axes1
set(zoom(hObject),'ActionPostCallback',@(x,y) XTickLabelCallbackFcn(hObject));
set(pan(hObject),'ActionPostCallback',@(x,y) XTickLabelCallbackFcn(hObject));
Error using uigetmodemanager (line 17) First argument must be a figure handle
Error in getuimode (line 12) hManager = uigetmodemanager(hFig);
Error in pan>locGetMode (line 290) hMode = getuimode(hFig,'Exploration.Pan');
Error in pan>locGetObj (line 220) hMode = locGetMode(hFig);
Error in pan (line 184) out = locGetObj(arg1);
댓글 수: 0
답변 (1개)
Adam
2018년 3월 14일
Both zoom and pan should take a figure handle, which, by default, will be
handles.figure1
in a callback (or in the OpeningFcn which is where I usually put such things).
I always rename the tag from 'figure1' to something more sensible, but whatever your tag is for your figure is what would replace 'figure1'
댓글 수: 2
Adam
2018년 3월 16일
편집: Adam
2018년 3월 16일
axes handles are not at all the same as figure handles. I am surprised you don't get an error with zoom if you are trying to use it with an axes handle.
A figure can contain any number of axes (or none at all) and the zoom function applies to the figure as a whole as the toolbar with the zoom icon is figure-level also. Though I notice in R2018a you can now add toolbars to axes, but they are not supported by having a zoom or pan object per axes so far as I can see.
참고 항목
카테고리
Help Center 및 File Exchange에서 Visual Exploration에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!