2

我希望更改titlelabelslegendingeom_col情节的and 。

我尝试使用下面的函数来更改legend title,但是没有任何反应:

labs(color = "Treatment")
labs(fill = "Treatment")

我还尝试使用更改图例标题和标签:

scale_fill_discrete(name = "Treatment", labels = c("Control", 
"Fertilization", "Shading", "Warming))

但是,绘图列改变颜色,我收到以下错误消息:

“填充”的比例已经存在。为“填充”添加另一个比例,它将替换现有比例。

我的代码如下所示:

bar.plot.selected.groups <- ggplot(mean_emission_p12_gr3, aes (x = date, y = 
avg_emission, fill = Treatment)) + geom_errorbar(aes(ymin = avg_emission - 
se, ymax = avg_emission + se), width = 0.5, position = position_dodge(width 
= 0.65)) + geom_col (position = "dodge", width=0.65) + theme(axis.text.x = 
element_text(size = 10, angle = 90, hjust=0, vjust = 0.5), axis.title = 
element_text(size = 14))

bar.plot.selected.groups + labs(x = "Date", y = "Emission rate (µg m-2 h- 
1)", color = treatment) + ggtitle("BVOC emission 2012") + theme(plot.title = 
element_text(size = 20, hjust = 0.5)) + facet_wrap(~ compound_gr_3, scales = 
"free") +  theme(strip.text.x = element_text(size = 12, color = "black", 
face = "bold")) + scale_fill_manual("legend", values = c("C" = "black", "F" 
= "green", "S" = "blue", "W" = "red"))
4

0 回答 0