0

I am plotting points on a map, with the following code

crime_poss_drugs$colorbucket<- as.numeric(cut(crime_poss_drugs$count,c(0,100,200,300,400,500,600,700,800,900,1100,Inf)))
crime_prod_drugs$colorbucket<- as.numeric(cut(crime_prod_drugs$count,c(0,100,200,300,400,500,600,700,800,900,1100,Inf)))
ggmap(Map) +
   geom_point(data = crime_poss_drugs,shape=22,
        aes(x = lon, y = lat, colour=factor(colorbucket)))+
   geom_point(data = crime_prod_drugs,
        aes(x = lon, y = lat,colour=factor(colorbucket)))

But the problem is, there are overlapping points from both the layers of geom_point(). Can any one please suggest me how to avoid overlapping in representation when they are at same latitude longitude position. Thanks for the help in advance.

alexwhan
  • 15,636
  • 5
  • 52
  • 66
user2934433
  • 343
  • 1
  • 5
  • 20
  • 1
    Would reducing the `alpha` help? This makes each point slightly transparent, so overlapping points appear darker than solitary ones. Try `geom_point(..., alpha = 3/8)` – Hugh Feb 28 '14 at 03:52
  • Thanks a lot, it kind of worked.Changed the shape to triangle and decreased the hue. Can you help how to change default colors after factor(colorbucket). Use different set of colors rather than the default. I am new to R – user2934433 Feb 28 '14 at 04:08
  • Look at `?scale_color_manual`. – Hugh Feb 28 '14 at 04:18
  • Thanks a lot. Could explore many options with your suggestion. – user2934433 Feb 28 '14 at 06:44

1 Answers1

0

Changing the alpha value is a good suggestion. One other option is to jitter the points, ie, add a bit of random noise so they do not collide as much. (This makes more sense in some contexts than others -- it's a substantive question, really.) Check out the geom_jitter docs if you are curious.