Why does boxplot ignore the hold command?
1 回表示 (過去 30 日間)
古いコメントを表示
Given the following code, MATLAB plots the first boxplot properly, but then overrides the vertical axis despite the hold command, ruining the data visualization. Why does this problem occur? How do I solve it?
Planned = 10*rand(100,1);
Measured = rand(100,1);
DoseIntervals = cell(100,1);
DoseIntervals(1:50) = {'1-5'}; DoseIntervals(51:100) = {'6-10'};
datatoplot = table(Planned,Measured,DoseIntervals,...
'VariableNames',{'Planned' 'Measured' 'DoseIntervals'})
figure
boxplot(datatoplot.Planned,datatoplot.DoseIntervals,'Colors','r')
hold on
boxplot(datatoplot.Measured,datatoplot.DoseIntervals,'Colors','b')
![](https://www.mathworks.com/matlabcentral/answers/uploaded_files/170147/image.png)
(This problem occurs when the second boxplot data has a smaller maximum than the first. Since we don't necessarily know which data set will be larger, plotting it first isn't always a feasible workaround.)
0 件のコメント
回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!