是否可以在 ggplot2 中使用 geom_smooth 显示标准差?

Sal*_*try 1 plot r ggplot2 dplyr

我目前使用 geom_smooth 函数来绘制细菌生长数据。

我想知道是否可以显示标准差而不是由标准误差计算的置信区间(我认为这是该函数的标准)

例子:

p1<-mtcars %>%
  ggplot(aes(x=mpg,cyl)) +
  geom_smooth( size=2, span=1,color="tomato",fill="tomato")
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

所以我的问题是:

  1. 是否可以使用 geom_smooth 显示运行标准差?
  2. 如果没有,还有其他方法可以实现这一目标吗?

预先非常感谢!

All*_*ron 7

现在可以直接在内部执行此操作,geom_smooth因为我们可以根据内部计算的标准误差计算出标准偏差after_stat

mtcars %>%
  ggplot(aes(mpg, cyl)) +
  geom_smooth(size = 2, span = 1, color = "tomato", fill = "tomato",
              aes(ymax = after_stat(y + se * sqrt(length(y))),
                  ymin = after_stat(y - se * sqrt(length(y))))) 
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述