【问题标题】:BoxPlot ideas in MATLABMATLAB 中的 BoxPlot 想法
【发布时间】:2018-02-01 17:39:53
【问题描述】:

我喜欢使用 3 种不同的方法为两张不同的公司图纸绘制分离堆栈的公差分布,如下图所示:

我喜欢盒子靠得更近、更宽。我试过位置,但没有用。显然,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'});

【问题讨论】:

  • 箱线图背后的主要思想是可视化你的分布,不知道它是否是参数化的。因此,中值估计量是描述数据的更好选择。在这里您可以看到解决方法:link。您应该考虑使用包含平均值的误差线图(在这种情况下,您可以假设您的数据是正态分布的)。

标签: matlab matlab-figure mean boxplot


【解决方案1】:

如果您想要更宽的箱线图,请不要使用紧凑样式:

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)

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2020-11-30
    • 1970-01-01
    • 2018-08-31
    • 1970-01-01
    • 2021-03-06
    • 2016-02-21
    • 2013-08-01
    相关资源
    最近更新 更多