好的,这里是你如何用akima
包插入表面。默认情况下,它将根据现有表面为您提供 40x40 网格:
require(akima)
require(reshape2)
temp.df<-expand.grid(x=2:4,y=2:4,z=0)
temp.df$z<-rnorm(9,10,3)
surface<-melt(interp(temp.df$x,temp.df$y,temp.df$z)) # melt() stretches out the surface to x,y,z as you've put into the original example
flat<-surface[!is.na(surface$X1)&!is.na(surface$X2),] # drop the NAs
#CONVERT SCALES BACK (INTERP GIVES YOU A 40x40 grid over the existing range)
points<-data.frame(x=min(temp.df$x)+(flat$X1-1)/(40/diff(range(temp.df$x))),
y=min(temp.df$y)+(flat$X2-1)/(40/diff(range(temp.df$x))),
z=flat$value)
wireframe((points$z ~ points$x + points$y),
scales=list(arrows=F),
screen = list(z = 40,x= -60)
)
