Matlab Boxplots

时间:2013-11-26 18:02:49

标签: matlab matlab-figure

我想创建一个准箱线图,如附件第15/16页所示。

comisef.eu/files/wps031.pdf

理想情况下,我只想显示报告中的中位数,最大值和最小值。

我也希望与报告中显示的内容类似。

目前我有两个矩阵,其中存储了所有必要的值,但不知道如何在matlab中执行此操作。

boxplot函数提供了太多的数据(异常值等),这使得结果图看起来很混乱,特别是当我尝试在原始报告中在一个页面上绘制200时。

是否有其他功能与matlab中的报告完全相同?

Baz

这里有一些测试数据,每行代表数据集的10组估计值,每列代表给定观察值的测试数据。

由于boxplot适用于输入矩阵的列,因此您需要转置矩阵。

是否可以关闭异常值和四分位数范围?理想情况下,我只想查看最大值,最小值和中值?

您可以重复以下数据,最多可达200​​.或者我可以在必要时发送更多数据。

0.00160329732202511 0.000859407819412016    0.000859407819411159      0.0659939338995606    0.000859407819416322    0.000859407819416519    2.56395024851142e-15    2.05410662537078e-14    0.000859407819416209
1.67023155116586e-06    8.88178419700125e-16    1.67023155115637e-06    0.000730536218639616    1.67023155105582e-06    3.28746017489609e-15    4.41416632660789e-15    1.67023155094400e-06    1.67023155097567e-06
1.42410590843629e-06    1.42410590840224e-06    1.76149166727218e-15    5.97790925044131e-15    1.42410590843863e-06    2.87802701599909e-15    9.31529385335274e-16    9.17306727455842e-16    0.000820358763518906
8.26849110292527e-16    3.23505095414772e-15    4.38139485761850e-07    4.38139485938112e-07    4.38139485981887e-07    0.000884647755317917    3.72611754134110e-15    4.38139485974329e-07    4.38139485923219e-07
0.000160661751819407    0.000870787937135265    0.000870787937136209    1.16934122581182e-15    9.02860049358913e-16    1.18053134896556e-15    1.40433338743068e-15    0.000870787937135929    1.13510916297112e-15
1.16934122581182e-15    3.80292342262841e-05    3.80292342263200e-05    0.00284904319356532 1.74649997619656e-15    3.80292342264024e-05    0.00284904319356537 1.01267920724547e-15    0.00284904319356540
   0.100091800399985    0.100091773169254   0.100091803903140   0.000770464183529358    0.100091812455930   3.49996706323281e-05    3.49996706323553e-05    1.05090687851466e-15    0.100091846333800
0.00100555294602561 0.00100555294601056 0.105365907420183   0.000121078082591672    9.02860049358913e-16    0.000121078082591805    4.49679158258033e-15    7.77684615168284e-16    0.000121078082591693
0.122539456858702   0.000363547764643498    0.000363547764643509    0.122516928568610   0.0101487499394213  0.122408366511784   0.000363547764643519    1.13510916297112e-15    0.122521393586646
0.000460749357561036    0.000460749357560646    3.27600489447913e-13    1.18053134896556e-15    0.000460749357561239    1.54689304063675e-15    0.000460749357560827    0.000460749357561205    1.16934122581182e-15

2 个答案:

答案 0 :(得分:2)

我认为这是一个玩设置的问题。你可以尝试:

boxplot(X, 'plotstyle', 'compact', 'colors', 'k', 'medianstyle', 'line', 'outliersize', 0);

Explanation:
'plotstyle', 'compact': makes the boxes filled and the lines undashed
'colors', 'k': color is black
'medianstyle', 'line': the median is marked by a line
'outliersize', 0: if outlier size is zero, you don't see them

Other you can try:
'orientation', 'vertical': this flips the orientation, depends on your data
'whisker', 10 (or higher): this sets the maximum whisker length as a function of the interquartile limits (if you crank it up, it will eventually default to max and min values), I wasn't sure if this is what you wanted. Right now, it goes to the 25th and 75th percentile values.

间距取决于您拥有的数据量。如果您使用某些数据进行编辑,我可以为您试用。

答案 1 :(得分:2)

我建议不要使用箱线图,而是从最小值到最大值绘制线条,并在中位数处做出标记。 Boxplot绘制了25到75百分位的盒子,这听起来不像你想要的那样。像这样:

% fake data
nPoints = 100;
data = 10*rand(10, nPoints);

% find statistics
minData = min(data, [], 1);
maxData = max(data, [], 1);
medData = median(data);

% x coordinates of each line. Change this to change the spacing.
x = 1:nPoints;

figure
hold on

%plot lines
line([x; x], [minData; maxData])
% plot cross at median
plot(x, medData, '+')

line plot for min, max and median

编辑:要有水平线和第二个轴,你可以这样做:

figure
h1 = subplot(1,2,1);
h2 = subplot(1,2,2);

% left subplot
axes(h1)
hold on
%plot lines
line([minData; maxData], [x; x])

% plot cross at median
plot(medData, x, '+')

% link the axes so they will have the same limits
linkaxes([h1,h2],'y')
% turn off ticks on y axis.
set(h2, 'YTick', [])

horizontal min, max, median line plot