MATLAB中的BoxPlot思路

问题描述 投票:0回答:1

我想用两种不同的公司图纸绘制分离堆栈的公差范围,如图所示:

tolerance spread

我喜欢盒子更紧密,更宽。我尝试了位置,但它没有用。显然,boxplot创造了中间线,所以总是在中间。我想要每个盒子的平均值,并用线条连接平均点。

 A=[...
   0.0189    0.00839   0.01542     NaN   0.217   0.1865   0.1985;
   -0.0303   -0.01979  -0.02682   NaN  0.107    0.1375   0.1255; ];
  figure('color', 'w');
c = colormap(lines(3));
 C = [c; ones(1,3); c];  % this is the trick for coloring boxes
boxplot(A, 'color', C, 'plotstyle', 'compact', ...
    'labels', {'','STACK A','','','','STACK F',''}); 
hold on;
for ii = 1:3
    plot('color', c(ii,:));
end
title('TOLERANCE SPREAD COMPARISON FOR GDOTs TDP');
ylabel('Tolerance (in)');
%xlabel('STACKS');
legend({'WC', 'RSS', 'MRSS'});
matlab matlab-figure mean boxplot
1个回答
0
投票

如果您想要更宽的箱形图,请不要使用紧凑型:

bh = boxplot(A, 'color', C,...
    'labels', {'','STACK A','','','','STACK F',''}); 

也可以将中位数更改为均值,执行以下操作:

% compute the mean by group & convert it to pairs of Y values:
M = mat2cell(repmat(mean(A).',1,2),ones(size(M,1),1),2);
% change the medians to means:
set(bh(6,:),{'YData'},M)
© www.soinside.com 2019 - 2024. All rights reserved.