带有预先计算值的geom_boxplot

use*_*932 11 r ggplot2 boxplot

在过去,我已经能够使用ggplot2通过提供较低的晶须,较低的分位数,中位数,较高的分位数和较高的晶须以及x轴标签来创建箱图.例如:

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()
Run Code Online (Sandbox Code Playgroud)

将为两组数据(A和B)制作一个箱线图.这不再适合我.我收到以下错误:

Error: Aesthetics must either be length one, or the same length as the dataProblems:x
Run Code Online (Sandbox Code Playgroud)

有没有人知道ggplot2中是否有某些变化?

San*_*att 15

这可以使用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")
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

请参阅此处的"使用预先计算的统计信息"示例