I am trying to automatically add multiple model evaluation parameters in lattice plot. I am using the following code
library(lattice)
library(tidyverse)
library(hydroGOF)
#Calculation of model evaluation parameters
summ <- iris %>%
group_by(Species) %>%
summarise(Rsq = cor(Sepal.Length, Petal.Length)^2,
RMSE = RMSE(Sepal.Length, Petal.Length),
NSE = NSE(Sepal.Length, Petal.Length)) %>%
mutate_if(is.numeric, round, digits=2)
#Make multipanel plot
xyplot(Petal.Length ~ Sepal.Length | Species, data = iris, pch = 23,
layout=c(3,1), type = c("p", "r"),
scales=list(cex=c(1.4,1.4), alternating=1, relation = "free"),
xlab = list(label="Sepal Length", fontsize=20),
ylab = list(label="Petal Length", fontsize=20))
which gives me the following plot

Now how can I have the following plot using lattice package

Edit
While adding panel.lmbands from mosaic package to solutions (1) and (3) works but I was unable to achieve it using solution (2). Here is the code
library(mosaic)
p2 <- xyplot(Petal.Length ~ Sepal.Length | Species, data = iris, pch = 23,
layout=c(3,1),
band.lty = c(conf =2, pred = 1),
band.lwd =c(conf =1, pred = 1),
npts = 500,
panel = panel.lmbands,
scales=list(cex=c(1.4,1.4), alternating=1, relation = "free"),
xlab = list(label="Sepal Length", fontsize=20),
ylab = list(label="Petal Length", fontsize=20),
panel = function(x, ...) {
i <- panel.number()
panel.xyplot(x, ...)
panel.key(as.expression(summ$ann[[i]]), points = FALSE)
})
p2
It returns me following error
Error in xyplot.formula(Petal.Length ~ Sepal.Length | Species, data = iris, : formal argument "panel" matched by multiple actual arguments
The expected output will look like the following

