我有一个使用ggplot2的双因素条形图,其中我使用mean_se添加了带有标准误差的误差条形图。我想使用标准差而不是标准差。
library(tidyverse)
#load diamonds dataset
diamonds <- diamonds
#two-factor dynamite plot
plt <- ggplot(diamonds, aes(cut, price, fill = color)) +
geom_bar(stat = "summary", fun.y = "mean", position = position_dodge(width =
0. 9)) +
geom_errorbar(stat = "summary", fun.data = "mean_se", position =
position_dodge(width = 0.9)) +
ylab("mean price") +
ggtitle("Two-Factor Dynamite plot")
plt
有没有一种方法可以做到这一点,类似于使用mean_se,但生成代表一个标准偏差的误差条?mean_sdl似乎不会这样做。谢谢。
发布于 2018-02-15 05:13:47
mean_sdl
接受参数mult
,该参数指定标准差的数量-默认情况下为mult = 2
。所以你需要通过mult = 1
plt <- ggplot(diamonds, aes(cut, price, fill = color)) +
geom_bar(stat = "summary", fun.y = "mean",
position = position_dodge(width = 0.9)) +
geom_errorbar(stat = "summary", fun.data = "mean_sdl",
fun.args = list(mult = 1),
position = position_dodge(width = 0.9)) +
ylab("mean price") +
ggtitle("Two-Factor Dynamite plot")
plt
https://stackoverflow.com/questions/48800212
复制