我想在下图中绘制发展轨迹,即点2009和2010应该用带箭头的线连接(指向2010),点2010和2011应该用带箭头的线连接(指向2011) ) 等等 ...
这应该适用于两组。
这是我到目前为止所做的:
library(ggplot2)
x <- c(100, 200, 300, 200, 500, 320, 300, 50)
y <- c(100, 250, 600, 700, 60, 120, 200, 360)
t <- rep(seq(2009,2012),2)
z <- rep(c("A","B"),each=4)
d <- as.data.frame(cbind(z,t,x,y))
d <- d[order(d$z, d$t),]
ggplot(data = d, aes(x = x, y = y, colour = z, label=t)) +
geom_line(aes(group = z)) +
geom_point() +
geom_text()
我的 2 个问题是:(1)“错误”点已连接,(2)箭头丢失。