Remove 'a' from legend when using aesthetics and geom_text

user2700207 picture user2700207 · Aug 20, 2013 · Viewed 31.3k times · Source

How can I can remove the letter 'a' from the legend generated by this code? If I remove the geom_text, then the 'a' letter will not show in the legend. I want to keep geom_text, though.

ggplot(data = iris, aes(x = Sepal.Length, y=Sepal.Width, shape = Species, colour = Species)) + 
   geom_point() + 
   geom_text(aes(label = Species))

Answer

Simon O'Hanlon picture Simon O'Hanlon · Aug 20, 2013

Set show.legend = FALSE in geom_text:

ggplot(data = iris,
       aes(x = Sepal.Length, y = Sepal.Width, colour = Species, shape = Species, label = Species)) + 
    geom_point() +
    geom_text(show.legend = FALSE)

The argument show_guide changed name to show.legend in ggplot2 2.0.0 (see release news).


Pre-ggplot2 2.0.0:

With show_guide = FALSE like so...

ggplot( data=iris, aes(x=Sepal.Length, y=Sepal.Width , colour = Species , shape = Species, label = Species ) , size=20 ) + 
geom_point()+
geom_text( show_guide  = F )

enter image description here