Data:
Morocco_ObsClim
Morocco_ProjClim
Code:
Morocco_ObservedClim <- read.csv(file = \"Morocco_ObservedClim.csv\", header=TRUE, se
I think you are overcomplicating things. Consider:
df <- subset(
Morocco_ProjectedClim,
DataFormat=="anom" & gcm %in% c("avg", "min", "max") & Timeframe=="annual",
select=c("sres", "Year", "gcm", "Temp")
)
df.cast <- dcast(df, sres + Year ~ gcm)
library(ggplot2)
ggplot(df.cast, aes(x=Year, y=avg)) +
geom_ribbon(aes(ymin=min, ymax=max, fill=sres), alpha=0.4) +
geom_line(aes(color=sres)) +
scale_fill_manual(values=c("tan1", "red3", "royalblue3", "palegreen3")) +
scale_color_manual(values=c("brown", "red", "blue", "green4"))
This does just the temperatures from the projected data set, but should give you a good idea on how to tackle the problem.
EDIT: this adds actuals:
ggplot(df.cast, aes(x=Year, y=avg)) +
geom_ribbon(aes(ymin=min, ymax=max, fill=sres), alpha=0.4) +
geom_line(aes(color=sres)) +
geom_line(
data=subset(Morocco_ObservedClim, DataSource == "avg" & DataFormat == "anom" & Timeframe == "annual"),
aes(x=Year, y=Temp, color="Actual")
) +
scale_fill_manual(values=c("tan1", "red3", "royalblue3", "palegreen3")) +
scale_color_manual(values=c(`20thC`="brown", A1B="red", A2="blue", B1="green4", Actual="black"))
Though note I didn't update the plot.