geom_boxplot与预先计算值geom_boxplot与预先计算值(geom_boxplot

2019-05-14 06:07发布

在过去,我已经能够通过与x轴标签一起提供较低的胡须,下分,中位数,上分位数,和上胡须创建使用GGPLOT2箱线图。 例如:

DF <- data.frame(x=c("A","B"), min=c(1,2), low=c(2,3), mid=c(3,4), top=c(4,5), max=c(5,6))
ggplot(DF, aes(x=x, y=c(min,low,mid,top,max))) +
geom_boxplot()

会使的箱线图用于两组数据(A&B)。 这不再是我的作品。 我得到以下错误:

Error: Aesthetics must either be length one, or the same length as the dataProblems:x

有谁知道,如果事情已经GGPLOT2被改变?

Answer 1:

这个工程使用GGPLOT2版本0.9.1(和R 2.15.0)

library(ggplot2)

DF <- data.frame(x=c("A","B"), min=c(1,2), low=c(2,3), mid=c(3,4), top=c(4,5), max=c(5,6))

ggplot(DF, aes(x=x, ymin = min, lower = low, middle = mid, upper = top, ymax = max)) +
  geom_boxplot(stat = "identity")

请参阅“使用预先计算的统计数据”的例子在这里



文章来源: geom_boxplot with precomputed values