【问题标题】:How to remove grey borders around individual entries in ggplot2 legend when using theme_bw?使用theme_bw时如何删除ggplot2图例中各个条目周围的灰色边框?
【发布时间】:2014-11-17 12:38:00
【问题描述】:

我在 R 中有以下代码:

library(ggplot2)
theme_set(theme_bw())
p <- ggplot(mtcars, aes(wt, mpg))
p <- p + geom_point(aes(colour = factor(cyl)))
p

导致:

每个图例条目周围都有一个灰色边框。怎么去掉?

【问题讨论】:

    标签: r ggplot2 legend


    【解决方案1】:

    只需添加

    + theme(legend.key = element_rect(colour = NA))
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-06-24
      • 1970-01-01
      • 2023-03-07
      • 2017-01-02
      • 1970-01-01
      • 1970-01-01
      • 2011-01-22
      • 2021-08-30
      相关资源
      最近更新 更多