我想绘制下面提到的图。我可以使用不同的颜色作为数据点,但是我怎么能把箭头放在他们身上呢? 我正在使用下面提到的声明。由于在R中显示不同颜色的GPS数据
plot(type ="o",c, d, xlab="longitude",ylab="latitude", main ="Path", col = 1:3);
我想绘制下面提到的图。我可以使用不同的颜色作为数据点,但是我怎么能把箭头放在他们身上呢? 我正在使用下面提到的声明。由于在R中显示不同颜色的GPS数据
plot(type ="o",c, d, xlab="longitude",ylab="latitude", main ="Path", col = 1:3);
可以生产使用geom_segment从GGPLOT2情节。下面 的代码显示了一个示例使用随机点:
require(ggplot2)
df <- data.frame(x = rpois(10, 5), y = rpois(10, 5), group = 1:10)
g <- ggplot(df, aes(x = x, y = y, color = as.factor(group)))
g <- g + geom_segment(aes(xend=c(tail(x, n=-1), NA),
yend=c(tail(y, n=-1), tail(y, n = 1))),
arrow=arrow(length = unit(0.5, "cm")))
g <- g + theme_bw() + theme(legend.position="none") + xlab("longitude") + ylab("latitude")
g
产生的情节是这样的:
请添加一些数据重复的例子很多:)祝天 – Niko