所以我有一个数据框,如:
time,candidate_id,allocation_id,final_score,position
data
...
然后我想制作一个ggplot2箱图。我希望这个boxplot为每个allocation_id
设置一个不同的框。我试着用:
ggplot(data=(allocation_info), aes(allocation_id, final_score))
但是我没有为每个allocation_id
获得多个箱图,而是获得了一个巨大的箱形图。有人知道为什么会这样吗?
答案 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))