参考自《R Graphics Cookbook》
本文针对ggplot2添加误差棒的一种方法:使用geom_errorbar()语法
library(ggplot2)
library(gcookbook)
library(dplyr)
一、柱形图加误差棒
#筛选部分数据来作图
ce_mod <- cabbage_exp %>%
filter(Cultivar == "c39")
ce_mod
#制图
ggplot(ce_mod, aes(x = Date, y = Weight)) +
geom_col(fill = "white", colour = "black") +
geom_errorbar(aes(ymin = Weight - se, ymax = Weight + se),
width = 0.2)
二、折线图加误差棒
#制图
ggplot(ce_mod, aes(x = Date, y = Weight )) +
geom_line(aes(group = 1)) +
geom_point(size &#