与填充审美GEOM_LABEL。在图例中删除信

问题描述 投票:0回答:1

我需要删除设置填充审美时会出现在geom_label传说中的“a”字母。使用show.legend = F删除整个填充图例,并使用guides(text = 'none')没有取得任何效果。

enter image description here

谢谢

r ggplot2 legend
1个回答
0
投票

我喜欢用一种解决方法是使用相同的期望的美学(Alpha设置为0,从而它不与所得到的曲线图干扰)添加另一个的geom层,从而使填充图例取决于而非geom_label层。示意图下:

# instead of this
p1 <- ggplot(mtcars, 
             aes(wt, mpg, fill = factor(cyl),
                 label = rownames(mtcars))) +
  geom_label()

# try this
p2 <- ggplot(mtcars, 
       aes(wt, mpg, fill = factor(cyl),
           label = rownames(mtcars))) +
  geom_label(show.legend = FALSE) +
  geom_tile(alpha = 0) +
  guides(fill = guide_legend(override.aes = list(alpha = 1)))

plot

(您可以使用geom_point层也一样,如果你喜欢的点状传奇钥匙。形状21-25填写接受作为审美。)

© www.soinside.com 2019 - 2024. All rights reserved.