为什么可以';我是否使用override.aes更改图例中的颜色?

为什么可以';我是否使用override.aes更改图例中的颜色?,r,ggplot2,aesthetics,R,Ggplot2,Aesthetics,我想从ggplot的填充图例中删除颜色线。我通常使用guide\u legend(override.aes=…)来修改图例美学-对点、线、alpha等非常有用,但对我的color美学不起作用。我做错了什么 # generate data set.seed(47) data = data.frame(year = rep(2000:2004, 3), value = runif(15), group = rep(c("A",

我想从ggplot的填充图例中删除颜色线。我通常使用
guide\u legend(override.aes=…)
来修改图例美学-对点、线、alpha等非常有用,但对我的
color
美学不起作用。我做错了什么

# generate data
set.seed(47)
data = data.frame(year = rep(2000:2004, 3),
                  value = runif(15),
                  group = rep(c("A", "B", "C"), each = 5))

# create the plot
p = ggplot(data, aes(x = year, y = value, fill = group)) +
    geom_area(position = position_fill(), color = "white") +
    scale_fill_grey()

# this should modify the fill legend to remove the colored line
# but the line is still there
p + guides(fill = guide_legend(override.aes = list(color = NA)))

这是
颜色
需要用
u
拼写的情况之一。添加
u
使
覆盖.aes
工作正常
ggplot2
自2016年以来的版本已修复了此错误,您可以使用任意一种拼写

p + guides(fill = guide_legend(override.aes = list(colour = NA)))

有一次我写文章的时候,我正为这个问题使劲地捶着我的头。。。