Reputation: 23898
I wonder if it is possible to show data values on levelplot (lattice package) in R. I'd appreciate if someone help me to do that. Thanks in advance.
Upvotes: 2
Views: 5372
Reputation: 68839
You can write your own panel function, e.g.:
library("lattice")
x <- seq(pi/4, 5*pi, length.out=10)
y <- seq(pi/4, 5*pi, length.out=10)
r <- as.vector(sqrt(outer(x^2, y^2, "+")))
grid <- expand.grid(x=x, y=y)
grid$z <- cos(r^2)*exp(-r/(pi^3))
p <- levelplot(z~x*y, grid,
panel=function(...) {
arg <- list(...)
panel.levelplot(...)
panel.text(arg$x, arg$y, round(arg$z,1))})
print(p)
Upvotes: 14