あなたは、プロットの初期構造を作成するためにboxplot
を使用して、あなたが望むものを表現するためにそれらを変更することができます。各マトリックスx
は1つのグリッドプロットに変換され、プロットはsubplot
と並んで配置されます。ここで
は、あなたがやりたいために短いコードです:
A = {rand(10,5)*2-1,rand(10,5)*2-1}; % your cell array
for n = 1:numel(A)
subplot(1,2,n)
x = A{n};
means = mean(x,2);
stds = std(x,[],2);
% create boxplot for all variables:
bx = boxplot(x.','Orientation','horizontal');
% remove what's unnecessary:
delete(bx([1:4 7],:))
% set the median to mean:
set(bx(6,:),{'XData'},...
mat2cell([means means],ones(size(x,1),1),2))
set(bx(6,:),{'Color','LineWidth'},{[1 0.7 0],3})
% set the interQ range to std:
std_bounds = repmat(means,1,5)+bsxfun(@times,stds,[-1 1 1 -1 -1]);
set(bx(5,:),{'XData'},mat2cell(std_bounds,ones(size(x,1),1),5))
set(bx(5,:),'Color',[0.8 0 0])
for k = 1:size(std_bounds,1)
patch(std_bounds(k,:),get(bx(5,k),'YData'),[0.8 0 0],...
'FaceAlpha',0.7,...
'EdgeColor','none')
end
xlim([-1 1])
ax = gca;
ax.Children = ax.Children([end 1:end-1]);
% create the grid:
set(ax,{'YGrid','GridColor','GridAlpha','XTick','XAxisLocation','YTick'},...
{'on','k',1,[-1 0 1],'top',(1:size(x,1))+0.5})
% set the zero line:
line(ax,zeros(size(x,1)+2,1),(0:size(x,1)+1).','LineStyle','--','Color','k')
if n>1
set(ax,'YTickLabel',[])
end
end
それは、この作成されます。
'サブプロット()'と '箱ひげ図()' –
は[見てみましょうをここから](https://stackoverflow.com/questions/39708175/hierarchically-grouped-boxplot) – EBH
@EBHで始まるいくつかのコードがあります。この例をありがとう。私はこれがボックスプロットの問題ではないと思う。基本的には、長方形のグリッドを、std devで平均値と面積値に対応する線でプロットする必要があります。 – Shraddha