remove a specific plot from multiple plots

5 visualizzazioni (ultimi 30 giorni)
Aditya Shanbhag
Aditya Shanbhag il 6 Feb 2016
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.

Risposte (1)

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

Accedi per commentare.

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by