0

我有兴趣在 Matlab 中创建这样的情节。 (来源:3rs-reduction.co.uk均值图

“像这样”我的意思是我希望有两组,分别称为 A 和 B,观察两次,预处理和后处理,其中该图由 A 和 B 在时间预处理时的箱形图的左组组成右侧组由治疗后 A 和 B 的箱线图组成,其中 A pre 的平均值通过一条线连接到 A post 的平均值,B pre 的平均值通过一条线连接到 B post 的平均值. 我并不是说需要维护颜色形状或线条(而不是框)的特定外观。

我尝试使用 boxplot 命令并使用“hold on”来到达那里,但我不太清楚如何将它们组合在一起。具体来说,假设就像在 Matlab 箱线图命令中一样,观察是在行中,字段是列,并且顺序是 ((A,pre),(A,post),(B,pre),( B,发布))。

要构建的一些示例代码:

simlength = 100;
groupmeans = [.1, .2, .2, .4];
groupstddev = [.05, .05, .05, .05];
simholder = randn(simlength,4);
simholder = repmat(groupmeans ,simlength,1) + simholder     .* repmat(groupstddev ,simlength,1);
boxplot(simholder)

如果我可以堆叠该箱线图的结果 1 和 3 以及结果 2 和 4 并在组之间画线,则意味着我会很高兴,只是不知道如何将所有部分放在一起。

谢谢!

4

2 回答 2

1

类似的东西怎么样:

x = rand(2, 1);           % ? maybe just leave out?
y = rand(2, 1);           % [mean(Apre), mean(Apost)]
e = rand(2, 1)*.2;        % ? is this maybe [std(Apre), std(Apost)]
errorbar(x, y, e, 'o-');  % You can leave off the x here if you don't need it

hold all

%Now repeat for B
x = rand(2, 1);
y = rand(2, 1);
e = rand(2, 1)*.2;
errorbar(x, y, e, '^-');

legend({'First series', 'Second Series'})
于 2013-07-24T12:50:20.443 回答
0

丹的回答很接近(谢谢!),但没有包括我需要模仿上图的格式细节。一旦我弄清楚如何做到这一点,我就尝试编辑他以添加所需的更改,但编辑并不关心我的更改。所以这就是我想要的。

y1 = rand(2, 1);           
e1 = rand(2, 1)*.2;       
errorbar(y1, e1, 'o-');  

hold all

%Now repeat for B
y2 = rand(2, 1);
e2 = rand(2, 1)*.2;
errorbar(y2, e2, '^-');
plotrange = [y1-e1;y2-e2;y1+e1;y2+e2];
yplotmin = min(plotrange)* .5;
yplotmax = max(plotrange) * 1.5;

legend({'Control', 'Treatment'})

set(gca,'YLim',[yplotmin yplotmax])
set(gca,'XLim',[.5 2.5])
set(gca,'XTick',1:2)
set(gca,'XTickLabel',{'Pre-treatment', 'Post-treatment'});

差异中的差异箱线图

于 2013-07-29T13:28:35.937 回答