4
我想在我的ggmap
對象(它是一個ggplot2
對象,據我瞭解)繪製線條(確切地說:geom_segment
元素)。在R中繪製ggmap對象上的geom_segment不顯示
我使用以下代碼:
library(ggmap)
mapImageData <- get_map(location = c(lon = (16.8 + (17.2-16.8)/2),
lat = (51 + (51.2-51)/2)),
color = "color",
source = "google",
maptype = "roadmap",
zoom = 11)
ggmap(mapImageData, extent = "device", ylab = "Latitude", xlab = "Longitude") +
geom_segment(aes(x = 51, y = 16.8, xend = 51.2, yend = 17.2))
一種清澈地圖正在繪製:
但無線(從geom_segment
)正在出現。我究竟做錯了什麼?
所以啞巴是我的問題...謝謝! = D –
特別是,如果有人遇到同樣的問題,使用aes時要小心!如果您指定新數據(例如您想繪製獨立於原始數據的段),則需要aes()。這就是爲什麼它不適合我。感謝這個例子,你也解決了我的問題! –