美文网首页
箱线图加中位数线

箱线图加中位数线

作者: 啊哈哈_1ba1 | 来源:发表于2025-02-04 16:01 被阅读0次
# 使用ggplot2画boxplot+中位数线
ggplot(df, aes(x=x, y=y)) + 
  geom_boxplot() + 
  stat_summary(fun=median, geom="line", aes(group=1))  + 
  stat_summary(fun=median, geom="point")

 # 使用ggplot2画boxplot+平均值线
ggplot(data, aes(x = Group, y = Value, fill = Group)) +
  geom_boxplot() +
  stat_summary(fun.y = "mean", geom = "point", size = 2) +
  stat_summary(fun.y = "mean", geom = "line", aes(group = 1, color = "orange"), size = 1.1)

# 使用ggplot2画boxplot+最大值线
ggplot(data, aes(x = Group, y = Value, fill = Group)) +
  geom_boxplot() +
  stat_summary(fun.y = "max", geom = "point", size = 2) +
  stat_summary(fun.y = "max", geom = "line", aes(group = 1,color="orange"), size = 1.1)

附linetype:

线的on/off延伸的长度:是通过包含 2 、 4、 6 或 8 个十六进制数字的字符串完成的,这些数字给出了连续长度的长度。例如,字符串“33”指 3 个单位 on,后跟 3 个off;“3313”指 3 个单位 on,然后是 3 个 off,然后是 1 个 on,最后是 3 个off。


image.png
image.png

相关文章

网友评论

      本文标题:箱线图加中位数线

      本文链接:https://www.haomeiwen.com/subject/jpiiujtx.html