带有预计算值的 geom_boxplot [英] geom_boxplot with precomputed values
本文介绍了带有预计算值的 geom_boxplot的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
过去,我已经能够使用 ggplot2 创建箱线图,方法是提供下须、下分位数、中位数、上分位数和上须以及 x 轴标签.例如:
In the past, I have been able to create boxplots using ggplot2 by providing the lower whisker, lower quantile, median, upper quantile, and upper whisker along with x-axis labels. For example:
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)制作箱线图.这不再适用于我.我收到以下错误:
would make a boxplot for two sets of data (A & B). This no longer works for me. I get the following error:
Error: Aesthetics must either be length one, or the same length as the dataProblems:x
有谁知道 ggplot2 中是否有什么变化?
Does anyone know if something has been changed in ggplot2?
推荐答案
这适用于 ggplot2 版本 0.9.1(和 R 2.15.0)
This works using ggplot2 version 0.9.1 (and 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")
请参阅使用预先计算的统计数据"示例此处
See the "Using precomputed statistics" example here
这篇关于带有预计算值的 geom_boxplot的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文