在matlab中有多个箱线图

Have multiple box plot in matlab

我在 matlab 中有两个箱线图,如下一个:

boxplot(input1(:,2), input1(:,1)) % time accompilishing a task among genders (male/female)
boxplot(input2(:,2), input2(:,1)) % time accompilishing a task among degree (bachelor/master)

我想要的是将两个图合成在同一个图中。因此,对于 x 轴中的四种情况,y 轴中有时间。我该怎么做?

您可以通过简单地垂直连接表格来解决这个问题:

input = [input1;input2];
boxplot(input(:,2), input(:,1))

这是假设 input1 中的组与 input2 中的组具有不同的键。例如。如果 male = 1female = 2bachelor = 1master = 2 它将 "mix" 和 类 而不会抛出错误。在那种情况下,您必须事先分配唯一键。