Why am I unable to generate box plots with the BOXPLOT function and place these plots in the axes created using the SUBPLOT function in MATLAB 7.0.4 (R14SP2)?
1 view (last 30 days)
Show older comments
MathWorks Support Team
on 27 Jun 2009
Commented: Walter Roberson
on 8 Jan 2016
When I execute the following commands, the figure window only diplays the last subplot:
pAbund = randn(16,5);
pIncorp = randn(16,5);
wpercent=[ones(size(pAbund)) 2*ones(size(pIncorp))];
wprobe=repmat([1:5],length(pAbund),2);
for i = 1:3
subplot(3,1,i)
boxplot([pAbund(:); pIncorp(:)],{wprobe(:) wpercent(:)})
end
However, the commands listed above execute as expected when the following command:
subplot(3,1,i)
is replaced with:
subplot(1,3,i)
Accepted Answer
MathWorks Support Team
on 18 Oct 2013
This bug has been fixed in Release 14 Service Pack 3 (R14SP3). For previous product releases, read below for any possible workarounds:
We have verified that there is a bug in the MATLAB 7.0.4 (R14SP2), Statistics Toolbox 5.0.2, with resizing the box plot when using the BOXPLOT function.
There are currently no known workarounds.
1 Comment
Walter Roberson
on 8 Jan 2016
Jacobo, when you subplot with a different arrangement of outputs (4 x 1 vs 1 x 7) then the later subplot() will delete all axes that it overlays; with the difference in sizes that is going to result in all of the subplot(4,1,*) being deleted, and in turn each of the subplot(4,1,j) is going to end up deleting several of the subplot(1,7,k).
If you want a 4 x 7 array of plots then you need to specify that
for j=1:4 % 4 output variables from simulations
for k=1:7 % 7 input factors which effect on output variables I plot
subplot(4,7,(j-1)*7 + k);
boxplot(LINACC(:,j),IMPCOND(:,k))
end
end
More Answers (0)
See Also
Categories
Find more on Axis Labels in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!