簡體   English   中英

如何在使用theme_bw時刪除ggplot2圖例中各個條目周圍的灰色邊框?

[英]How to remove grey borders around individual entries in ggplot2 legend when using theme_bw?

我在R中有以下代碼:

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

結果如下:

傳奇中的ggplot2灰色邊框

每個圖例條目都有一個灰色邊框。 如何刪除它?

只需添加

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

在此輸入圖像描述

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM