Use copyobj for specific properties -> subplot

조회 수: 3 (최근 30일)
klaus ebert
klaus ebert 2015년 5월 29일
댓글: klaus ebert 2015년 5월 30일
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
Jan
Jan 2015년 5월 30일
Which labels do you mean?
klaus ebert
klaus ebert 2015년 5월 30일
the xlabel and ylabel of my original axes, which is plotted on my maingui-figure.

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

답변 (1개)

Jan
Jan 2015년 5월 30일
The documentation of cla reveals, how to clear the contents of a specific axes:
axesH = subplot(2,2,[1,3]);
cla(axesH);
  댓글 수: 1
klaus ebert
klaus ebert 2015년 5월 30일
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.

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

카테고리

Help CenterFile Exchange에서 Subplots에 대해 자세히 알아보기

태그

제품

Community Treasure Hunt

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

Start Hunting!

Translated by