【发布时间】:2020-04-27 14:37:56
【问题描述】:
感谢这个论坛的帮助,我设法使用ggplot2 绘制了一条平均线和一条五分位线。
DF<-data.frame(DOB = c(1965, 1 949, 1964, 1979, 1960, 1992, 1991, 1963, 1964, 1992, 1971, 1965),
trip.duration.hr =c(3.36, 2.25, 5.31, 10.7, 1.96, 4.33, 23.55, 3.92, 5.46, 3.45, 13.72, 7.33))
我在下面插入了我的代码。我想做的是
- 为绘图区域内的平均线和五分之一线添加标签。
- 它目前将 x 轴刻度分解为 20 年间隔。所以 1940, 1960 等等。我可以把它缩小一点,所以每 5 年 是 x 轴上的单独标记点吗?
ggplot(DF, aes(x=DOB, y=trip.duration.hr)) +
geom_jitter(alpha=1/10) +
geom_line(stat = 'summary', fun.y = "mean", color="orange", size=1) +
geom_line(stat = 'summary', fun.y = "quantile", fun.args = list(probs = .9), linetype=2, color="red")
【问题讨论】: