R geom_平滑线条颜色与扩散颜色不同
出于某种原因,在我的图表中,几何平滑线的颜色与阴影区域的颜色不同。我不确定这是什么原因造成的。例如,用蓝色着色的已退休的有一条绿线,用绿色着色的无符号的有一条蓝线。激活状态正确R geom_平滑线条颜色与扩散颜色不同,r,ggplot2,R,Ggplot2,出于某种原因,在我的图表中,几何平滑线的颜色与阴影区域的颜色不同。我不确定这是什么原因造成的。例如,用蓝色着色的已退休的有一条绿线,用绿色着色的无符号的有一条蓝线。激活状态正确 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,
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")
问题是您更改了默认的
填充
颜色,而不是颜色
,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")
可能是因为您正在更改填充默认值,而不是颜色?ie尝试添加
scale\u color\u brewer(palete=“Set1”)
@user20650确实就是这个原因;发布为答案?就是这样,请发布为答案。
p <- p + scale_colour_brewer(palette = "Set1")