标签: r ggplot2
我希望垂直线相交后不要超出曲线线
# example data: x <- 1:50 dat <- data.frame(x = x, y = 1 - exp(-x/43)^4) ggplot(dat, aes(x = x, y = y)) + geom_line() + geom_vline(xintercept = c(10, 20, 30), lty = "dashed")
答案 0 :(得分:3)
改为使用 geom_segment :
ggplot(dat, aes(x = x, y = y)) + geom_line() + geom_segment(aes(x = x, xend = x, y = min(dat$y), yend = y), data = dat[ dat$x %in% c(10, 20, 30), ], lty = "dashed")