I have the following code:
drawCombinedSeries <- function(data, xData, yData, dataGroup, title, fileName, outputPath) {
plt <- ggplot(data, aes(x = xData, y = yData, fill = dataGroup)) +
stat_summary(geom = "line", size=1, fun = mean, aes(color=dataGroup, group = dataGroup)) +
stat_summary(geom = "ribbon", fun.data = mean_se, alpha = 0.3, aes(fill = dataGroup)) +
labs(title = title, x="Month", y="") +
theme(legend.position="bottom", axis.title.x = element_blank(), text = element_text(size=12, colour="black")) +
scale_x_discrete(name = "Month", limits=c(1:12), expand = c(0,0))
setwd(outputPath)
ggsave(filename=fileName, width=10, height = 2.5)
return(plt)
}
This function returns this plot:
What I desire is to change the colors of the lines to a grayscale, and rename the legend.
I tried to use theme_bw(), but it doesn't work because I already have my theme(). Regarding the legend, when I try to create my own legend, it only creates one for the last stat_summary, which is the ribbon, thus having two legends. I have looked for a way to deal with two stat_summary functions, because I think that's the issue, but I haven't found anything enlightening.