Matlab箱线图
我想创建一个准箱线图,如所附报告第15/16页所示 comisef.eu/files/wps031.pdf 理想情况下,我只想显示报告中的中值、最大值和最小值 我还希望有与报告中所示类似的间距 目前我有两个矩阵,其中存储了所有必要的值,但不知道如何在matlab中实现这一点 boxplot函数提供了太多的数据(异常值等),这使得生成的图形看起来很混乱,特别是当我试图在一页上绘制200个数据时,就像在原始报告中一样 是否还有其他函数可以实现与matlab中报告中相同的功能 巴兹 这里有一些测试数据,每行代表一个数据集的10组估计值,每列代表一个给定观测值的测试数 由于箱线图在输入矩阵的列上工作,因此需要转置矩阵 是否可以关闭异常值和四分位范围?理想情况下,我只想看到最大值、最小值和中值 您可以重复下面的数据,得到最多200个。或者,如果需要,我可以发送更多数据Matlab箱线图,matlab,matlab-figure,Matlab,Matlab Figure,我想创建一个准箱线图,如所附报告第15/16页所示 comisef.eu/files/wps031.pdf 理想情况下,我只想显示报告中的中值、最大值和最小值 我还希望有与报告中所示类似的间距 目前我有两个矩阵,其中存储了所有必要的值,但不知道如何在matlab中实现这一点 boxplot函数提供了太多的数据(异常值等),这使得生成的图形看起来很混乱,特别是当我试图在一页上绘制200个数据时,就像在原始报告中一样 是否还有其他函数可以实现与matlab中报告中相同的功能 巴兹 这里有一些测试数据
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
我认为这是一个玩设置的问题。您可以尝试:
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.
间距将取决于您拥有的数据量。如果你用一些数据编辑,我可以帮你试试 我认为这是一个玩设置的问题。您可以尝试:
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.
间距将取决于您拥有的数据量。如果你用一些数据编辑,我可以帮你试试 我建议不要使用箱线图,而是从最小值到最大值画一条线,并在中间值做一个标记。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, '+')
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', [])
编辑:要有水平线和第二个轴,可以执行以下操作:
% 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, '+')
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', [])
我建议不要使用箱线图,而是从最小值到最大值画一条线,并在中间值做一个标记。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, '+')
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', [])
编辑:要有水平线和第二个轴,可以执行以下操作:
% 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, '+')
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', [])
实际上,我开始认为箱线图不适合这个问题。我认为这更接近我想要的:与示例类似,我可以计算中值、man和min,并用max和min表示误差条绘制中值(似乎可以使用非对称误差条)。你知道如何控制误差条的间距吗?啊,不,不对称的误差条似乎不起作用。你必须根据另一个变量绘制数据。实际上,我开始认为箱线图不适合这个问题。我认为这更接近我想要的:与示例类似,我可以计算中值、man和min,并用max和min表示误差条绘制中值(似乎可以使用非对称误差条)。你知道如何控制误差条的间距吗?啊,不,不对称的误差条似乎不起作用。你必须根据另一个变量绘制数据。是的,更像是这样,很抱歉建议使用错误的箱线图。我想将这张图旋转90度,有效地转换这些值,然后将其与另一张图并排绘制,以便(理想情况下)它们共享相同的y轴(在上面的例子中,旋转后的坐标是1-100。但是每个坐标都有自己的x轴。请看我原始问题中的pdf。可以吗?啊,是的,更像是这样,很抱歉提出了错误的箱线图。我想将这张图旋转90度,有效地转换这些值,然后用Another并排绘制r图形,以便(理想情况下)它们共享相同的y轴(在上面的示例中,旋转后的y轴为1-100。但每个都有自己的x轴。请参阅我原始问题中的pdf。可以这样做吗?