how to show/hide colorbar by using menu
조회 수: 54 (최근 30일)
이전 댓글 표시
hi. i want to show and hide a colorbar by using menu. this is my code. it shows the colorbar but it cant hide it. plz help me to fix the problem.
function colorbar_Callback(hObject, eventdata, handles)
axes(handles.axes1)
if(get(colorbar,'enable','off'))
set(colorbar,'visible','on')
else
set(colorbar,'visible','off')
end
댓글 수: 0
답변 (1개)
Adam Danz
2019년 12월 31일
편집: Adam Danz
2020년 1월 14일
This line below should throw an error (r2019b).
get(colorbar,'enable','off')
Error using matlab.graphics.illustration.ColorBar/get
Too many input arguments.
The get() command only has one input, the handle.
Instead, you want to check that the 'Enable' property of the colobar is set to 'off':
function colorbar_Callback(hObject, eventdata, handles)
axes(handles.axes1)
if strcmpi(get(colorbar,'enable'),'off')
set(colorbar,'visible','on')
else
set(colorbar,'visible','off')
end
Lastly, avoid using 'colorbar' as a variable name since it will override the function call colorbar().
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Colorbar에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!