function boxPlot3D1(xx,g1,g2,quantDistribution)
%function boxPlot3D(xx,g1,g2,quantDistribution)
%--------------------------------------------------------------------------
% boxPlot3D(x) creates a three dimensional box plot of the data in x. If x
% is 3D a matrix, boxPlot3D creates one box for each column. Example,
% create a 3D matrix with normal distributions with different means:
%
% xx=randn(50,2,4)+repmat((permute([0 1 2 -2;1 2 3 4],[3 1 2])),[50,1,1]);
% boxPlot3D(xx)
%
% boxPlot3D(x,g1,g2) groups the data of x, with the grouping variables of
% g1, and g2. Example, create a 1D Matrix with different values and the
% corresponding grouping parameters:
%
% xx=randn(500,1)+linspace(0,5,500)';
% g1= [0.1*ones(250,1);0.2*ones(250,1)];
% g2= [3*ones(150,1);4*ones(150,1);5*ones(200,1)];
% boxPlot3D(xx,g1,g2)
%
% boxPlot3D(x,[],[],quantDistribution) allows the selection of the
% quantiles to select, e.g. [0 0.25 0.5 0.75 1]
% [0 0.25 0.5 0.75 1] (default) creates a box between 0.25 and 0.75
% with a line in 0.5 and two planes at 0 and 1
% connected with a dashed line. These values can be
% changed.
% [ 0 1] creates a box within the extremes of the values
% selected. These values can be changed, e.g.
% [0.25 0.75]
% [ 0.25 0.5 0.75] creates a box and a line, same as the option with
% 5 values, but will not draw the planes with the
% dashed line.
% The colours of the boxes can be changed in the code.
%--------------------------------------------------------------------------
%
%
if nargin <1
else
figure
hold on;
if ~exist('quantDistribution','var')
% Calculate the positions of the edges of the boxplot, and the
% quantiles at 25,50 75%
quantDistribution = [0 0.25 0.50 0.75 1 ];
end
if ~exist('g1','var')
% Only one parameter received, the data is in a 3D Matrix with one
% column per group.
[columns,levels] = size( xx);
global counterCols
for counterCols = 1:columns
for counterLevs = 1:levels
% Select columns, extract positions, and call display
% The column is directly extracted from the matrix
currentColumn = xx{counterCols,counterLevs};
% The positions correspond to the extreme, median and 25%/75%
% positions of the distribution, these are obtained with
% quantile
currentPositions = quantile(currentColumn,quantDistribution);
display3Dbox(counterCols,counterLevs,currentPositions);
end
end
else
% Three arguments, the data and two grouping parameters
% all should be the same size. First, detect the unique cases of
% each of the grouping parameters
cases_g1=unique(g1);
cases_g2=unique(g2);
% Count how many cases there are for each dimension
num_g1 = numel(cases_g1);
num_g2 = numel(cases_g2);
% The separation may vary and not necessarily be 0,1,2,3...
width_g1 = min(diff(cases_g1));
width_g2 = min(diff(cases_g2));
for counterCols = 1:num_g1
current_g1 = cases_g1(counterCols);
address_g1 = (g1==current_g1);
for counterLevs = 1:num_g2
current_g2 = cases_g2(counterLevs);
address_g2 = (g2==current_g2);
% Select columns, extract positions, and call display
% The column is directly extracted from the matrix
currentColumn = xx((address_g1)&(address_g2));
% The positions correspond to the extreme, median and 25%/75%
% positions of the distribution, these are obtained with
% quantile
currentPositions = quantile(currentColumn,quantDistribution);
% Call the display with the extra parameters for width
display3Dbox(current_g1,current_g2,currentPositions,width_g1,width_g2);
end
end
end
view(3)
rotate3d on
axis tight
grid on
end
end
没有合适的资源?快使用搜索试试~ 我知道了~
资源推荐
资源详情
资源评论
收起资源包目录
三维箱线图.rar (6个子文件)
tu2.tif 2.58MB
SMF箱线图用的数据groupboxplot.csv 30KB
main1.m 2KB
tu1.png 466KB
display3Dbox.m 4KB
boxPlot3D1.m 4KB
共 6 条
- 1
资源评论
神经网络机器学习智能算法画图绘图
- 粉丝: 2439
- 资源: 599
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功