Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in R Programming by (5.3k points)
edited by

How can I 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))

1 Answer

0 votes
by
edited by

You can set the show.legend argument in the geom_text function to FALSE to avoid the “a” in the legend.i.e., 

ggplot(data = iris,

       aes(x = Sepal.Length, y = Sepal.Width, colour = Species, shape = Species, label = Species)) + 

  geom_point() +

  geom_text(show.legend = FALSE)

Output:

image

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 4, 2019 in R Programming by leealex956 (7.3k points)
0 votes
1 answer
0 votes
1 answer
0 votes
1 answer
...