Don't like ads? PRO users don't see any ads ;-)
Guest

Untitled

By: a guest on Jul 17th, 2012  |  syntax: None  |  size: 0.75 KB  |  hits: 14  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. How to change ggplot legend labels and names with two layers?
  2. require(ggmap)
  3.  
  4. sp <- get_map('sao paulo', zoom=11, color='bw')
  5. restaurants <- data.frame(lon=c(-46.73147, -46.65389, -46.67610),
  6.                           lat=c(-23.57462, -23.56360, -23.53748))
  7. suppliers <- data.frame(lon=c(-46.70819,-46.68155, -46.74376),
  8.                         lat=c(-23.53382, -23.53942, -23.56630))
  9. ggmap(sp)+geom_point(data=restaurants, aes(x=lon, y=lat),color='blue',size=4)+geom_point(data=suppliers, aes(x=lon, y=lat), color='red', size=4)
  10.        
  11. dat <- rbind(restaurants,suppliers)
  12. dat$grp <- rep(c('Restaurants','Suppliers'),each = 3)
  13.  
  14. ggmap(sp) +
  15.     geom_point(data=dat, aes(x=lon, y=lat,colour = grp),size = 4) +
  16.     scale_colour_manual(values = c('red','blue'))