使用美学和geom_text时,从图例中删除“a” [英] Remove 'a' from legend when using aesthetics and geom_text

查看:213
本文介绍了使用美学和geom_text时,从图例中删除“a”的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我怎样才能从该代码生成的图例中删除字母'a'?如果我删除 geom_text ,那么'a'字母不会显示在图例中。不过,我想保留 geom_text

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


解决方案

设置 show.legend = FALSE $ geom_text

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

参数 show_guide 改名为 show.legend 位于 ggplot2 2.0.0 查看新闻发布)。




Pre < ggplot2 2.0.0



使用 show_guide = FALSE 像这样...

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


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))

解决方案

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 )

这篇关于使用美学和geom_text时,从图例中删除“a”的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆