一个我一生都找不到答案的简单问题:
只要看看ggplot2的错误栏参数,我怎样才能从
ymin
中删除aes()
?
我希望我的绘图尽可能简单,我觉得看到 ymax 就足够了。
geom_errorbar(position=position_dodge(0.8), width=.6, aes(ymin=mean+sem, ymax=mean+sem), size=4)
这就是我想要的:
http://forums.ni.com/t5/DIAdem-Idea-Exchange/Error-bars-for-a-Bar-Plot/idi-p/1682644
该问题没有数据集,所以我使用
diamonds
来说明解决方案。
包
superb
有一个重新定义的几何对象,称为 geom_superberrorbar()
。它有一个名为 pointing
的参数,可以是 "up"
、"down"
或 "both"
(默认)。
与
superb()
结合使用可以轻松自动计算平均值和置信区间:
library(superb)
library(ggplot2)
#load diamonds dataset
diamonds <- diamonds
superb( price ~ cut + color, diamonds,
# send the following arguments to the geom_superberrorbar:
errorbarParams = list( color="black",pointing = "up")
) +
ylab("mean price") +
ggtitle("One-ended Dynamite plot")
你得到: