我使用谷歌地图库
有以下代码library(ggmap)
map <- get_map(location = 'Asia', zoom = 4)
mapPoints <- ggmap(map)
我不得不画两点
mapPoints +
geom_point(aes(x = lon, y = lat, col = "orange"), data = airportD)
现在我想在这些点之间画一条线,我怎样才能获得这个结果?
答案 0 :(得分:3)
与向任何其他ggplot
对象添加图层不应该有任何不同。
airports <- read.csv("https://raw.githubusercontent.com/jpatokal/openflights/master/data/airports.dat", header = TRUE)
names(airports) <- c("id", "name", "city", "country", "code",
"icao", "lat", "lon", "altitude", "timezone", "dst", "tz")
airportD <- airports[airports$city %in% c("Beijing", "Bangkok", "Shanghai"), ]
map <- get_map(location = 'Asia', zoom = 4)
mapPoints <- ggmap(map)
mapPoints +
geom_point(aes(x = lon, y = lat), col = "orange", data = airportD)
mapPoints +
geom_line(aes(x = lon, y = lat), col = "orange", data = airportD)