0

I want to add a legend to my ggmap+geom_point, but I can't make it after multiple tries. Hope to get your help! Thanks.

bbox = c(-22.23, -39.19, 62.29, 38.43)
m = get_stamenmap(bbox = bbox, zoom = 6, maptype = "terrain-background")
points_ar = data.frame(lat = ar$lat, lon = ar$lon)
points_ca = data.frame(lat = ca$lat, lon = ca$lon)
points_eu = data.frame(lat = eu$lat, lon = eu$lon)

ggmap(m) + geom_point(aes(x=lon, y=lat), colour="brown", size = 0.5, data = points_ar)+ 
  geom_point(aes(x=lon, y=lat), colour="orange", size = 0.5, data = points_ca) +
  geom_point(aes(x=lon, y=lat), colour="purple", size = 0.5, data = points_eu)
camille
  • 15,634
  • 17
  • 33
  • 53
yizhou
  • 1
  • 2
    Take a look at the ggplot docs and the tutorials they link to. I'd recommend taking a step back to first learn how ggplot is intended to work, e.g. with variables assigned to visual encodings (e.g. color), rather than multiple calls to the same geom. To do that, you'll probably want to put all your data into a single data frame; without a [reproducible example](https://stackoverflow.com/q/5963269/5325862), it's hard to know exactly what that might look like – camille Aug 10 '21 at 20:14

0 Answers0