Example:
par.settings = list(clip = list(
library(lattice)
dat <- iris
COLOR <- c("red", "blue", "green")
#with the setting to allow text label outside plotting panel
xyplot(Sepal.Length ~ Sepal.Width, dat, group = dat$Species, col = COLOR,
par.settings = list(clip = list(panel = FALSE)),
panel = function(x, y, ...){
panel.xyplot(x, y, ...)
panel.text(x = c(4.5, 1.8, 3), y = c(4.5, 5.3, 8.5), label = levels(factor(dat$Species)), col = COLOR)
}
)
#Under the default setting, the labels are cut off as you can see below
xyplot(Sepal.Length ~ Sepal.Width, dat, group = dat$Species, col = COLOR,
panel = function(x, y, ...){
panel.xyplot(x, y, ...)
panel.text(x = c(4.5, 1.8, 3), y = c(4.5, 5.3, 8.5), label = levels(factor(dat$Species)), col = COLOR)
}
)