Mapping data values ​​on levelplot in R

I wonder if it is possible to show the data values ​​on a levelplot (lattice packet) in R. I would appreciate if anyone would help me do this. Thanks in advance.

+2
r graphics lattice
source share
1 answer

You can write your own panel function, for example:

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) 

panel.levelplot example

+13
source share

All Articles