remove a specific plot from multiple plots

2 views (last 30 days)
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.

Answers (1)

Walter Roberson
Walter Roberson on 6 Feb 2016
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 Comments
Aditya Shanbhag
Aditya Shanbhag on 7 Feb 2016
Apologies. It's not the opening function. It's just a generic function.Thanks
Walter Roberson
Walter Roberson on 7 Feb 2016
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.

Sign in to comment.

Categories

Find more on Migrate GUIDE Apps in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!