Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/r/66.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
R geom_平滑线条颜色与扩散颜色不同_R_Ggplot2 - Fatal编程技术网

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")