Copying (copyobj) boxplot from anova1 to new subplot

2 views (last 30 days)
Hi all.
I am using the anova1 function to produce a set of boxplots, which I then want to copy to a subplot alongside another figure.
When I do that using the code below, the boxes themselves scale perfectly fine, but it groups the boxes with the axis from the original figure and neglects to scale them, meaning in the subplot there are two axis set, one linked to the boxes but scaled wrong, and one on the subplot that work fine (see bottom plot in image). Any ideas on how to fix this?
Code:
stats = anova1(lam);
% Prepare ANOVA boxplot for copying
f = gcf;
axis off
hgsave(f,'two.fig')
close(f)
% Create figure
figure;
a1 = subplot(2,1,1);
First subplot code
a2 = subplot(2,1,2);
f_c = openfig('two.fig');
%Copy boxplot
hg1 = get(gca,'Children');
ch = get(hg1,'Children');
set(a2,'Xlim',[0,11])
copyobj(ch,a2)
close(f_c);
delete('two.fig');

Accepted Answer

Dale
Dale on 11 Nov 2013
Solved by putting
set(gca,'xticklabel',{''})
after the openfig command. For some reason removing the labels using set(gca,'xticklabel',[]) wouldn't work

More Answers (0)

Community Treasure Hunt

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

Start Hunting!