x <- rnorm(10)
y <- rnorm(10)
if (require(lattice)) xyplot( y ~ x,
panel = function(x, y, ...) {
panel.xyplot(x, y, ...)
grid.text2("some text\nwith a nice\nbackground")
grid.text2( expression( sum(x[i], i==1, n)^2 ), x=0.8, y=0.8 )
grid.text2( paste("sum of rnorm(10): ", sum(rnorm(10)) ), x=0.2, y=0.2, just="left" )
grid.text2( "horizontal justifications work too", x=0.95, y=0.35, just="right" )
})
## will work for multi-panel plots as well
Run the code above in your browser using DataLab