ggplot2 boxplots对我没有任何意义,为什么会发生这种情况?

时间:2012-08-10 22:03:08

标签: r ggplot2 boxplot

所以我有一个数据框,如:

time,candidate_id,allocation_id,final_score,position data ...

然后我想制作一个ggplot2箱图。我希望这个boxplot为每个allocation_id设置一个不同的框。我试着用:

制作一个
ggplot(data=(allocation_info), aes(allocation_id, final_score))

但是我没有为每个allocation_id获得多个箱图,而是获得了一个巨大的箱形图。有人知道为什么会这样吗?

1 个答案:

答案 0 :(得分:4)

您需要包含组或颜色审美:

data(mpg)
ggplot(data=mpg) + geom_boxplot(aes(x=cyl, y=displ, group=cyl))

因此,对于您的特定数据集,它将类似于:

ggplot(data=(allocation_info), aes(allocation_id, final_score)) + 
    geom_boxplot(aes(group=allocation_id))