使用美学和 geom_text 时从图例中删除“a" [英] Remove 'a' from legend when using aesthetics and geom_text
本文介绍了使用美学和 geom_text 时从图例中删除“a"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何从此代码生成的图例中删除字母a"?如果我删除 geom_text
,则a"字母将不会显示在图例中.不过,我想保留 geom_text
.
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))
推荐答案
在geom_text
中设置show.legend = FALSE
:
ggplot(data = iris,
aes(x = Sepal.Length, y = Sepal.Width, colour = Species,
shape = Species, label = Species)) +
geom_point() +
geom_text(show.legend = FALSE)
参数 show_guide
在 ggplot2 2.0.0
(查看发布新闻).
预ggplot2 2.0.0
:
使用 show_guide = FALSE
就像这样......
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 = FALSE)
这篇关于使用美学和 geom_text 时从图例中删除“a"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文