R lattice:如何制作自定义轴

R lattice: how to make custom axis

我正在使用 R lattice 包中的 levelplot。 我想用我的自定义刻度和标签制作轴。目前,我有以下内容:

我希望两个轴都标记如下:-pi、-0.5pi、0、0.5pi、pi 等...

是这样的吗?

library(lattice)

x <- seq(pi / 4, 5 * pi, length.out = 100)
y <- seq(pi / 4, 5 * pi, length.out = 100)
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))

levelplot(z ~ x * y, grid, cuts = 50,
          scales = list(y = list(at = c(pi, 2 * pi, 3 * pi, 4 * pi),
                                 label = c("pi", "2pi", "3pi", "4pi"))))

顺便说一句,下次请创建您自己的可重现示例。