I know how to join points using ggplot():
我知道如何使用ggplot()连接点:
dd <- data.frame(a=c(21.01223,18.45598,17.04542,19.44312),b=c(52.22968,51.75925,50.12482, 51.78745),
g=rep(1:2,2))
library(ggplot)
ggplot(data=dd,aes(x=a,y=b,group=g)) +
geom_point(col=rep(c("darkred","black"),each=2),size=5)+
geom_line(linetype=3)
but how to join this points on google map ? I can only draw the points, but how to join them ?
但是如何在谷歌地图上加入这些点呢?我只能画出这些点,但是怎么加入呢?
library(ggmap)
qmap('Poland',zoom=6) +
geom_point(data=dd,aes(x=a,y=b),col=rep(c("darkred","black"),each=2),size=5)
1 个解决方案
#1
2
To join the points you can pass the data into the geom_line()
geom as well.
要连接这些点,还可以将数据传递到geom_line() geom中。
library(ggmap)
myMap <- get_map("Poland", zoom = 6)
ggmap(myMap) +
geom_point(data=dd, aes(x=a,y=b), col=rep(c("darkred","black"), each=2), size=5) +
geom_line(data=dd, aes(x=a, y=b, group = g))
#1
2
To join the points you can pass the data into the geom_line()
geom as well.
要连接这些点,还可以将数据传递到geom_line() geom中。
library(ggmap)
myMap <- get_map("Poland", zoom = 6)
ggmap(myMap) +
geom_point(data=dd, aes(x=a,y=b), col=rep(c("darkred","black"), each=2), size=5) +
geom_line(data=dd, aes(x=a, y=b, group = g))