出于某种原因,在我的图表中,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")
感谢任何想法。
答案 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")
所以现在fill
和colour
美学被映射到不同的配色方案。
删除有问题的scale_fill_brewer
或为colour
p <- p + scale_colour_brewer(palette = "Set1")