Reputation: 45
I know how to join points using 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)
Upvotes: 3
Views: 455
Reputation: 8333
To join the points you can pass the data into the geom_line()
geom as well.
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))
Upvotes: 2