remove a specific plot from multiple plots
14 次查看(过去 30 天)
显示 更早的评论
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.
0 个评论
回答(1 个)
Walter Roberson
2016-2-6
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 个评论
Walter Roberson
2016-2-7
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.
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!