Quantcast
Channel: Active questions tagged r - Stack Overflow
Viewing all articles
Browse latest Browse all 201839

Need helping changing legend title in ggmap using scale_color_gradient2

$
0
0

I have created a ggmap with points sized and color coded by "count". Therefore, the legend displays "count" as the title when I would like it to be "Visitors". Here is the code:

ggmap(sites_map) +
  labs(x = "Longitude", y = "Latitude", title = "Home Location of Paying Visitors from Kansas") +
  coord_cartesian(xlim = c(-94, -102), ylim = c(36.9, 39.8)) +
  geom_point(data = sites, aes(x = longitude, y = latitude, colour= count), alpha = 0.7, size= sites$count) +
  scale_color_gradient2(low="green", mid="yellow", high="red", midpoint=15,
                        breaks=c(1,10,20,max(sites$count)), labels=c("1", "10", "20", "30")) +
  theme(text=element_text(size=15)) +
  geom_point(data = sites, colour = "blue", alpha = 0.5, mapping = aes(x = long, y = lat), size = sites$count, shape = 13) +
  ggsave("kansascolormap.png")

I'm new to coding, so I know it's messy! Here is the current map generated, linked below: image of map


Viewing all articles
Browse latest Browse all 201839

Trending Articles