问题描述
我使用geom_smooth绘制了一些数据,并寻找一种方法来改变每行的标准错误阴影的颜色以匹配该行(即,红线会使其标准错误显示为红色)。我浏览了官方ggplot2文档以及opts()列表。任何建议(或只是确认是否可能)赞赏。
I'm plotting some data using geom_smooth and looking for a way to change the color of the standard error shading for each line to match that line (ie., a red line would have it's standard error shaded red). I've looked through the official ggplot2 documentation as well as the list of opts() at https://github.com/hadley/ggplot2/wiki/%2Bopts%28%29-List. Any advice (or just confirmation of whether or not it's possible) is appreciated.
推荐答案
您的(可理解的)错误是认为你应该改变颜色而不是填充。标准错误阴影基本上是由 geom_ribbon
构成的,它们是2d区域,所以它们填充的颜色由填充
,而不是 color
。
Your (understandable) mistake is to think that you should be changing the color rather than the fill. The standard error shadings are made with geom_ribbon
essentially, and they are a 2d area, so the "color" they are "filled" with is determined by fill
, not colour
.
试试:
geom_smooth(aes(...,fill = variable))
其中变量与您映射到其他地方的颜色相同。
where variable is the same one you map to colour elsewhere.
这篇关于更改geom_smooth的标准错误颜色的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!