简体   繁体   中英

3D plot tick labels do not match with axis values (R lattice)

I am using the below code to create a 3D plot.

The plot looks almost exactly as I want. The only problem is that the tick labels of the x and y axes do not reflect the value range of the x and y vectors, but correspond to the number of elements in the respective vectors. Interestingly though, despite z depends on x and y, the value range of the z-axis is correct.

What I'd like to obtain is a plot where the x and y axes have four tick marks whose value ranges between 0 and 1, like the value of the underlying vectors.

Any help is greatly appreciated.

transfmv1 <- function (x, y) {
  return (log(1/((x+y)*x)+1))
}

x <- seq(0.1, 1, len=20)
y <- x
z1 <- outer(x, y, transfmv1)


require(lattice)
require(graphics)
wireframe(z1,
          xlab=list(label="Source country", cex=0.8),
          ylab=list(label="Destination\n country", cex=0.8),
          zlab=list(label="Multiplication\n factor", cex=0.8),
          screen=list(z=-40, x=-60, y=0),
          scales=list(arrows=F),
          colorkey=F,
          drape=T, col.regions=gray.colors(1000, start = 0.3, end = 0.9, gamma = 2.2, rev = FALSE))

在此处输入图像描述

You can specify the x / y values defining the grid as row.values and column.values arguments (see ?wireframe.matrix ), so just add

wireframe(z1,
          # ...
          row.values = x, column.values = y)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM