[英]How to change background colour of legend in ggplot2?
您可以使用theme
的legend.key
參數。 從?theme
:
legend.key
:圖例鍵下方的背景(element_rect()
;繼承自rect
)
那是
theme(legend.key = element_rect(fill = "black"))
一個例子:
a <- seq(1:5)
b <- seq(1:5)
c <- seq(1:5)
d <- data.frame(a, b, c)
ggplot(data = d, aes(x = a, y = b, color = factor(c))) +
geom_point() +
theme(legend.key = element_rect(fill = "yellow"))
產生:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.