Transfuring plots in GUI's

1 view (last 30 days)
Chris E.
Chris E. on 17 Jul 2014
Commented: Chris E. on 18 Jul 2014
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!

Accepted Answer

Geoff Hayes
Geoff Hayes on 18 Jul 2014
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 Comment
Chris E.
Chris E. on 18 Jul 2014
Thank you for being through in your answer! You are a great help!

Sign in to comment.

More Answers (0)

Community Treasure Hunt

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

Start Hunting!