0

I have a problem getting the legend in ggplot2 to correspond to the color in the figure. And I have extra variables in the legend. I have read many posts on similar issues but unfortunately I have not been able to apply those to this situation - successfully at least. I tried using "fill" and "scale_fill_manual()", "theme()" and several others, but to no avail yet. Hopefully I am just missing something simple here, I appreciate any suggestions!

I am making a map and my code right now is:

ggplot()+ geom_map(data=world, map=world,aes(x=long, y=lat, map_id=region),color="white", fill="#7f7f7f", size=0.05)+
   geom_point(aes(x=long.a,y=lat.a, size=var.p, color="red", alpha=0.5))

The plot looks like this:

enter image description here

MrFlick
  • 195,160
  • 17
  • 277
  • 295
Carla
  • 11
  • 3
  • Move the color and alpha outside of the `aes()` since they are not mapped to your data: `geom_point(aes(x=long.a,y=lat.a, size=var.p), color="red", alpha=0.5)` – MrFlick Jun 27 '18 at 19:12
  • Yep you got it! I swear I tried that at one point because I moved them inside aes(), but I don't know where I had them, ha. Thank you very much! – Carla Jun 28 '18 at 01:19

0 Answers0