How can I include a reference table or legend for a geom_point geographical map?

105 views Asked by At

I am generating a map very similar to this this
(source: dominodatalab.com)
] to visualize the frequency in which cities occur. How can I create a legend or key for this map so I can see what the size of the circles represent numerically?

Here is my code:

myLocation <- c(-124, 32, -66, 42)

myMap <- get_map(location = myLocation, source = "stamen",
                 maptype = "toner", crop = FALSE, zoom = 4)

ggmap(myMap) +
geom_point(aes(x = lon, y = lat), data = csr.Ax1,
           col = "orange", alpha = 0.4, size = csr.Ax1$freq*.25) +
scale_size_continuous(range = range(csr.Ax1$freq), guide = "legend") +
ggtitle("CSR Active Candidates") +
legend()

EDIT: SOLVED!

The solution was placing the size=csr.Ax1$freq from the geom_point argument into the aes() argument.

1

There are 1 answers

0
depizza On

The solution was placing the size=csr.Ax1$freq from the geom_point argument into the aes() argument.