如何从此代码生成的图例中删除字母“a”?如果我删除 geom_text ,则图例中不会显示“a”字母。不过,我想保留 geom_text

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

最佳答案

show.legend = FALSE 中设置 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)
参数 show_guideshow.legend ( see release news ) 中将名称更改为 ggplot2 2.0.0

ggplot2 2.0.0 :
像这样 show_guide = FALSE ......
ggplot(data = iris, aes(x = Sepal.Length, y = Sepal.Width , colour = Species,
                        shape = Species, label = Species ), size = 20) +
geom_point() +
geom_text(show_guide  = FALSE)
使用美学和 geom_text 时从图例中删除  'a'-LMLPHP

关于使用美学和 geom_text 时从图例中删除 'a',我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/18337653/

10-12 18:55