I am trying to add a legend to each plot output of the ccl4model(ODE model) in the deSolve package using plot.deSolve and the legend method but it only appears on the last plot output of the model. I would like for each legend to appear on each plot output of the model
library(deSolve)head(ccl4data) #observed dataobs <- subset(ccl4data, animal == "A", c(time, ChamberConc))names(obs) <- c("time", "CP")parms <- c(0.182, 4.0, 4.0, 0.08, 0.04, 0.74, 0.05, 0.15, 0.32, 16.17, 281.48, 13.3, 16.17, 5.487, 153.8, 0.04321671, 0.40272550, 951.46, 0.02, 1.0, 3.80000000)#Scenario 1yini <- c(AI = 21, AAM = 0, AT = 0, AF = 0, AL = 0, CLT = 0, AM = 0)out <- ccl4model(times = seq(0, 6, by = 0.05), y = yini, parms = parms)#Scenario 2par2 <- parms; par2[1] <- 0.1out2 <- ccl4model(times = seq(0, 6, by = 0.05), y = yini, parms = par2)#Scenario 3par3 <- parms;par3[1] <- 0.05out3 <- ccl4model(times = seq(0, 6, by = 0.05), y = yini, parms = par3)#Plotting all the scenariosplot.deSolve(out, out2, out3, which = c("AI","MASS", "CP"), col = c("black", "red", "green"), lwd = 2, obs = obs, obspar = list(pch = 18, col = "blue", cex = 1.2))legend("topright", lty = c(1,2,3,NA), pch = c(NA, NA, NA, 18), col = c("black", "red", "green", "blue"), lwd = 2, legend = c("par1", "par2", "par3", "obs"))