Use copyobj for specific properties -> subplot

3 Ansichten (letzte 30 Tage)
klaus ebert
klaus ebert am 29 Mai 2015
Kommentiert: klaus ebert am 30 Mai 2015
Hello everyone, at the moment I'm trying to create a callback function which copies the main properties of some of my GUIs axes to a subplot in a new window. The problem is that I don't know how to select just some specific properties and leave out others. My callback works fine with
plotdata= findall(handles.axes1);
plotdata=plotdata(2:end);
%or plotdata=get(Axeshandle,'children'); but this doesn't give me the labels for example
sp=subplot(2,2,[1,3]);
copyobj(plotdata,sp);
but in this case it also copies the locations of the labels so that they seem misplaced on my subplot. The properties I'm interested in copying are: -xlim -ylim -xtick -ytick -the plot(with colour) -xlabel(with colour, font and size) -ylabel (with colour, font and size)
The rest, like the position of the subplot, should remain as in the default subplot-settings.(so that labels do not cross each other)
Is there a way to get all properties mentioned above into a structure which I can copy with copyobj?
And a second questions relating to this is whether there is a command to clear the subplot before using copyobj.
At the moment the plots overwrite each other. (I tried "cla;" but this clears all the subplots and not a particular one. "clear subplot(2,2,[1,3]);" doesnt work either.) It works if I do it with the subplot handles and always delete the handle previously to the plotting but then I also have to check if the subplot handle exists, which gives me another ifloop and kind of seems too complex for such a simple task)
Thank you for your help! Klaus
  2 Kommentare
Jan
Jan am 30 Mai 2015
Which labels do you mean?
klaus ebert
klaus ebert am 30 Mai 2015
the xlabel and ylabel of my original axes, which is plotted on my maingui-figure.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Jan
Jan am 30 Mai 2015
The documentation of cla reveals, how to clear the contents of a specific axes:
axesH = subplot(2,2,[1,3]);
cla(axesH);
  1 Kommentar
klaus ebert
klaus ebert am 30 Mai 2015
The problem is, that if I use this before replotting the new graph (which is what I intend to do) the field is afterwards non existent.
So if something is plotted on subplot 1 for example and this plot should be completely replaced by another plot my code looks like this:
handles.sp1=subplot(2,2,1);
%....
cla (handles.sp1);
handles.sp1=subplot(2,2,1);
copyobj(plotdata,handles.sp1);
But in this case the copyobj gives me the error that sp1 is non existent.

Melden Sie sich an, um zu kommentieren.

Tags

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by