R geom_point and ggmap

霸气de小男生 提交于 2019-11-27 06:31:55

问题


I want to plot a ggmap in R, for example, of Australia and have a layer of data points with markers corresponding to the size specified by the following data:

sitename   lat    lon    sitenum
Sydney     -34    151    1
Melbourne  -37    144    4
Adelaide   -34    138    7

Here's my code, but it's not working...

library(ggmap)
map <- get_map(location = 'Australia', zoom = 4)
mapPoints <- ggmap(map) + geom_point(aes(x = lon, y = lat, size = sitenum), alpha = .5)

回答1:


You need to pass the points as the data argument to geom_points. If they are in the data.frame pp, then the following will owrk

ggmap(map) + geom_point(data = pp, aes(x =lon, y= lat,size = sitenum), alpha=0.5)



来源:https://stackoverflow.com/questions/19262805/r-geom-point-and-ggmap

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!