如何在boxplot中添加行(手动最小/最大允许值)

时间:2017-02-20 14:28:59

标签: matlab matlab-figure

我尝试使用MATLAB中的:boxplot(x,g)命令在箱线图中显示某些测量数据。有一本手册给出了最小和最大允许值。如何将此值添加到箱形图中,如下面的彩绘屏幕截图所示?

How it should look

1 个答案:

答案 0 :(得分:2)

您可以执行以下操作(使用boxplot后):

max_bounds = [2 3 2]; % set the maximum bound by category
min_bounds = [-1 -2 -1]; % set the minimum bound by category
x = repmat(1:numel(max_bounds),[2 1]); % make x values for all categories
x = bsxfun(@plus,x,[-0.1; 0.1]); % make the lines in length of 0.2
hold on
% plot it all:
plot(x,repmat(min_bounds,[2 1]),'r',x,repmat(max_bounds,[2 1]),'r')

boxplot