我想在R中绘制一些3d图并使用wireframe命令,但是我看不到数据,只能看到一个空盒子,里面什么也没有。
library(lattice)
x <- c(38.02, 49.56, 132.98, 55.65, 129.44, 83.04 ,103.52, 99.59, 100.13)
y <- c(2.35 ,2.39 ,5.41 ,0.55 ,3.12 ,0.41 ,0.31 ,0.47 ,0.37 )
z <- c(-63, -42, -27, -21, -18, -9, -4.5, -3, -1.5)
wireframe(y ~ z*x, drape=TRUE,
xlab = "loss",
ylab = "tree",
zlab = "mass")
我该如何绘制?
答案 0 :(得分:0)
假设您使用的是点阵包装,这可能会起作用。
library(lattice)
x <- c(38.02, 49.56, 132.98, 55.65, 129.44, 83.04, 103.52, 99.59, 100.13)
y <- c(2.35, 2.39, 5.41, 0.55, 3.12, 0.41, 0.31, 0.47, 0.37)
z <- c(-63, -42, -27, -21, -18, -9, -4.5, -3, -1.5)
df <- data.frame(expand.grid(x, y, z))
colnames(df) <- c("x", "y", "z")
wireframe(y ~ z * x, drape = TRUE,data = df,
xlab = "loss",
ylab = "tree",
zlab = "mass")