我有以下带有均值和置信区间的汇总数据,是使用 SummarySEwithin 计算的。我用它来生成下面的图。
绘图代码如下:
ggplot(df_forplot, aes(x=Phase, y=criterion, colour=Phase)) +
geom_line(aes(x=Phase, y=criterion, group=1))+geom_point() +
geom_errorbar(aes(ymin=criterion-ci, ymax= criterion+ci),width=.1) +
scale_colour_manual(values= c("#3399FF", "#FF3366"))+
theme(legend.position = "none")+ mytheme
我想将线条颜色更改为黑色。我如何实现这一目标?
正如 Carl 上面指出的,如果您想将绘图图层中的某个特征(例如颜色)更改为固定值(因此它不依赖于数据),您需要在
aes(...)
之外指定它。我在下面的代码片段的第二行中添加了 , colour="black"
片段。
试试这个代码:
ggplot(df_forplot, aes(x=Phase, y=criterion, colour=Phase)) +
geom_line(aes(x=Phase, y=criterion, group=1), colour="black")+geom_point() +
geom_errorbar(aes(ymin=criterion-ci, ymax= criterion+ci),width=.1) +
scale_colour_manual(values= c("#3399FF", "#FF3366"))+
theme(legend.position = "none")+ mytheme