0

How can I remove the extra legend which results from this R code?

I have been reading for hours, but still cannot fix this issue and it is killing me. Below is my code:

ggmap(Yak_base) + 
  stat_bin2d(
    aes(x = Yak_dat[,2], y = Yak_dat[,1], colour = Yak_Ind, fill = Yak_Ind),
    size=.10, bins = 60, alpha = 1/2, data = Yak_dat_fort
  ) + 
  geom_polygon(aes(x = Yak_coord[,1], y = Yak_coord[,2]), data = Yak_coord,
               colour = 'black', fill = NA, alpha = 0.4,
               size = 0.75
  ) +
  labs(x = "Longitude", y = "Latitude") + ggtitle("Yakima Subbasin") + 
  scale_fill_discrete(
    name = "Indicator for Snow", labels = c("No Snow","Snow")
  )
B. Washington
  • 139
  • 1
  • 6
  • You can do that with `override.aes`. See [here](http://stackoverflow.com/questions/29947887/duplicate-legend-with-geom-vline-in-ggplot) and [here](http://stackoverflow.com/questions/32780092/legend-in-ggplot2-remove-level) for some examples. – Jaap Oct 16 '15 at 21:07
  • I was guessing that because you didn't give the `colour` legend the same labels and name as `fill` you are getting two legends instead of one. See [here](http://stackoverflow.com/questions/31610202/r-ggplot2-single-legend-when-using-group-linetype-and-colour) or [here](http://stackoverflow.com/questions/23343333/ggplot2-shape-color-and-linestyle-into-one-legend?lq=1) if this is your problem (and consider adding a [reproducible example](http://stackoverflow.com/questions/5963269/how-to-make-a-great-r-reproducible-example)). – aosmith Oct 16 '15 at 22:00

0 Answers0