我试图使用 ggplot vline 和 hline 在线图上显示截距,但希望线条在图上的截距点处停止。在 ggplot 中这可能吗还是有其他解决方案
library(ggplot2)
pshare <- data.frame()
for (i in 1:365) {
pshare <- rbind(pshare,c(i, pbirthday(i,365,coincident=3)))
}
names(pshare) <- c("number","probability")
x25 <- qbirthday(prob = 0.25, classes = 365, coincident = 3) #61
x50 <- qbirthday(prob = 0.50, classes = 365, coincident = 3)
x75 <- qbirthday(prob = 0.75, classes = 365, coincident = 3)
p <- qplot(number,probability,data=subset(pshare,probability<0.99))
p <- p + geom_vline(xintercept = c(x25,x50,x75))
p <- p + geom_hline(yintercept = c(0.25,0.5,0.75))
p
例如,我希望 0.25/61 线在它们在绘图上相遇时结束
TIA