remove a specific plot from multiple plots

I have a plot that looks like this.
I want get the value selected from the menu and when the 'REMOVE' button is pressed hide that respective plot. I have two callbacks and a generic function.
I tried doing the following
When plotting in some function
hdle=plot(H(n-(i-1),:)+(i-1),'color',C{m});
setappdata(hObject.Parent,strcat('handle',num2str(i)),hdle); %setappdata for all the plots with handle name 'handle'+ plotnumber
In callback function
num=getappdata(hObject.Parent,'popupval'); %get value from popupmenu
plotrmv=getappdata(hObject.Parent,strcat('handle',num2str(num))); %get handle selected
set(plotrmv,'Visible','off'); %hide the plot
delete(plotrmv); %delete it
But the plot isn't deleted or hidden.What could the problem be? Thanks.

답변 (1개)

Walter Roberson
Walter Roberson 2016년 2월 6일

0 개 추천

uicontrol do not have an opening function callback. If you are executing the setappdata in an opening function callback then the parent will not be the uicontrol.
uicontrol do have a CreateFcn callback.
The documentation for the CreateFcn property of uicontrol says to use gcbo to get the handle of the uicontrol. This appears to be behaviour special to CreateFcn and DeleteFcn (and figure ResizeFcn); see http://www.mathworks.com/help/matlab/ref/gcbo.html

댓글 수: 2

Apologies. It's not the opening function. It's just a generic function.Thanks
How is the code that is doing the plot being called? Are you passing the uicontrol handle as its first parameter, or is it a callback for the uicontrol?
My suspicion is that the uicontrol is not the parent of the hObject at the time you call the routine.

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

질문:

2016년 2월 6일

댓글:

2016년 2월 7일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by