从stat_summary到geom_函数

IlN*_*o92 1 r ggplot2

我想使用geom_函数而不是stat_summary在这里重写绘图.有什么建议?

感谢您的关注.

library(ggplot2)
ggplot(data = mpg)+
  stat_summary(
    mapping = aes(x = class, y = hwy),
    fun.ymin = min,
    fun.ymax = max,
    fun.y = median
  )
Run Code Online (Sandbox Code Playgroud)

在此输入图像描述

Rol*_*and 5

ggplot(data = mpg)+
  geom_pointrange(
    mapping = aes(x = class, y = hwy),
    fun.ymin = min, #passed to the stat via the ...
    fun.ymax = max, #ditto
    fun.y = median, #ditto
    stat = "summary"
  )
Run Code Online (Sandbox Code Playgroud)