我有以下数据框:
df <- data.frame(
time = factor(c(1, 1, 2, 2)),
value = c(1, 5, 3, 4),
group = factor(c(1, 2, 1, 2)),
upper = c(1.1, 5.3, 3.3, 4.2),
lower = c(0.8, 4.6, 2.4, 3.6)
)
我想将“值”列绘制为一条线,然后绘制一个“低于”最小点较低且最大点较高的区域。
到目前为止,我有这个:
ggplot(df, aes(time, value, colour = group)) +
geom_line(aes(group = group)) +
geom_errorbar(aes(ymin = lower, ymax = upper), width = 0.2)