geom_smooth线颜色不同于传播颜色

时间:2018-04-24 15:02:20

标签: r ggplot2

出于某种原因,在我的图表中,geom_smooth线的颜色与阴影区域的颜色不同。我不确定是什么造成的。例如,蓝色的退役阴影有绿线,绿色的无符号阴影有蓝线。活动状态是正确的。

qb_height_rating_scat <- ggplot(qb_stats, aes( x = height_in_inches, y = passer_rating, fill = current_status) )

qb_height_rating_scat + geom_point(shape=21, size=2.5) + 
  stat_smooth(method=loess,size=1.2, span=.6, aes (color = current_status)) +
  labs(x = "Height in Inches", y = "Average QB Passer Rating", title = "Average QB Passer Rating to Height Relationship") + 
  scale_fill_brewer(palette = "Set1")

Here is the result of the graph.

Here is the csv

感谢任何想法。

1 个答案:

答案 0 :(得分:1)

问题在于您更改了默认的fill颜色,而不是colour,em,颜色。

使用iris数据集

p <- ggplot(iris, aes(Sepal.Width, Sepal.Length, fill=Species)) +
            geom_point(shape=21, size=2.5) + 
            stat_smooth(method=loess,size=1.2, span=.6,aes (color=Species)) + 
            scale_fill_brewer(palette = "Set1")

所以现在fillcolour美学被映射到不同的配色方案。 删除有问题的scale_fill_brewer或为colour

添加其他内容
p <- p + scale_colour_brewer(palette = "Set1")