在误差条中仅显示 ymax ggplot2

问题描述 投票:0回答:1

一个我一生都找不到答案的简单问题:

只要看看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

r ggplot2
1个回答
0
投票

该问题没有数据集,所以我使用

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")

你得到:

mean plot with error bars pointing up only

© www.soinside.com 2019 - 2024. All rights reserved.