ggplot2中geom_segment函数的用法
1、
> coor <- data.frame( x = c(3,4,5),y = c(10,20,30), + xend = c(2.5,3.5,4.5), yend = c(20,30,10)) > coor x y xend yend 1 3 10 2.5 20 2 4 20 3.5 30 3 5 30 4.5 10 > ggplot(mtcars, aes(x = drat, y = mpg)) + geom_line() + + geom_segment(data = coor, aes(x = x, y = y, xend = xend, yend = yend), + lty = 1, colour = "red")