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)
Was it helpful?

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)

enter image description here

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top