gpt4 book ai didi

r - 绘制自定义垂直线直至曲线

转载 作者:行者123 更新时间:2023-12-05 03:04:20 25 4
gpt4 key购买 nike

希望垂直线相交后不超出曲线

示例数据:

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")

enter image description here

最佳答案

改用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")

enter image description here

关于r - 绘制自定义垂直线直至曲线,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/53084380/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com