Transfuring plots in GUI's

1 次查看(过去 30 天)
Hello all!
Well I'm trying to transfer plots in gui's and it is not quite working the way I want it to...
I have attached the files that I made to show the issue.
So here is the problems: Titles, label's, log-plots, and some cases the colors all do not transfer right...
Run one or both of the GUI's and then press "reset" button to plot some data, then press the transfer button to transfer the data over to the other plot. I hope this demonstrates the issue I am having.
I'm hoping there is a fix out there!
please help,
Thanks!

采纳的回答

Geoff Hayes
Geoff Hayes 2014-7-18
Chris - you can use the allchild function to get a list of all children of the specified object (including those ones with hidden handles). So in your code, you could replace
copyobj(get(h.axes1,'children'),handles.axes1);
with
copyobj(allchild(h.axes1),handles.axes1);
The above change would be made in the pushbutton1_Callback function for both GUIs, and seems to allow the copying of titles and axis labels from one GUI to another. I say seems, because the copying of the histogram works well, but that for the logarithmic plot is messy and incomplete.
I could only get the correct colour of the histogram to be copied successfully if I explicitly defined/set the colour in the testplot2.m file. In pushbutton2_Callback, I added the following code after the call to hist
h = findobj(gca,'Type','patch');
set(h,'FaceColor',[0 .5 .5],'EdgeColor','w');
The above is taken from the Change Histogram Color Properties of hist.
As for the loglog plot - yikes. The title wouldn't copy, the x and y axis labels were in the incorrect place, and the plot itself was way off...but it was the correct colour! Replacing the loglog with the simpler
x=-2*pi:0.0001:2*pi;
y=sin(x);
plot(x,y,'r');
demonstrated that this data (and title and axis labels) could be copied over successfully. It appears that the XData and YData is copied over from one figure to the other, but without the logarithmic scaling.
As an aside, in your code, the axes1 tag kept getting cleared (this is a known issue) after the loglog or plot, so I had to add as the last line in both pushbutton2_Callback functions, the following
set(handles.axes1,'Tag','axes1');
just to reset the tag value.
  1 个评论
Chris E.
Chris E. 2014-7-18
Thank you for being through in your answer! You are a great help!

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by