0

I am using ggmap to create a map with points. The size of the point reflects the value of the variable.

mapPoints <- ggmap(map) + 
             geom_point(aes(x = Lat, y = Lon, size = KaskoAntal), 
               data = mydata, alpha = .7, colour = "#E32B2E") + 
             scale_size(range = c(2, 15))

The map looks good, but I would like to change a few things. I tried a lot of tutorials, but I haven't been able to find a solution to my the below issues:

1) I would like to change the legend heading "KaskoAntal" to something else

2) I would like to format the numbers with thousand separator

3) Right now, the legend shows the following scale / bubble size: 100, 200, 300, 400. How can I control the scale?

Any help / leads are greatly appreciated.

tonytonov
  • 25,060
  • 16
  • 82
  • 98
hgaronfolo
  • 331
  • 1
  • 3
  • 9
  • Basicly, `ggmap` package is based on `ggplot2, so look for `ggplot2` functions for changing specific element of graph i.e scale_colour_manual, scale_x_continuous. Plenty of them you find on docs.ggplot2.org. – Maciej Mar 28 '14 at 12:27
  • This can also be an useful resource http://www.cookbook-r.com/Graphs/Legends_(ggplot2)/ – Edwin Mar 28 '14 at 14:36
  • Thank you. The problem with the above tutorials / documentation is that they show how to change the X or Y. In my case X and Y are Latitude and Longitude.. But the variable that controls the size is KaskoAntal (Not on the axis).. So my question is: How can I change the legend for a plotted variable which is not on the X Y scale? – hgaronfolo Mar 31 '14 at 12:10

1 Answers1

0

1) I would like to change the legend heading "KaskoAntal" to something else

Add + labs(size = "New name").

2) I would like to format the numbers with thousand separator

Add + scale_size_continuous(label=scales::comma) (for KaskoAntal).

3) Right now, the legend shows the following scale / bubble size: 100, 200, 300, 400. How can I control the scale?

Add + scale_size_continuous(breaks = c(100, 200, 300, 400)).

All of those changes of KaskoAntal's name, formatting, and bubble size refer to size because you defined size = KaskoAntal.

Roman
  • 4,744
  • 2
  • 16
  • 58