简体   繁体   English

3D plot 刻度标签与轴值不匹配(R 格)

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

I am using the below code to create a 3D plot.我正在使用以下代码创建 3D plot。

The plot looks almost exactly as I want. plot 看起来几乎完全符合我的要求。 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.唯一的问题是xy轴的刻度标签并不反映 x 和 y 向量的取值范围,而是对应于各自向量中的元素个数。 Interestingly though, despite z depends on x and y, the value range of the z-axis is correct.有趣的是,尽管 z 取决于 x 和 y,但 z 轴的取值范围是正确的。

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.我想要获得的是 plot ,其中 x 和 y 轴有四个刻度线,其值范围在 0 和 1 之间,就像基础向量的值一样。

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您可以将定义网格的 x / y 值指定为row.valuescolumn.values arguments(参见?wireframe.matrix ),所以只需添加

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

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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