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)
Question
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)
Solution
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)