2

我有一个问题,经过一段时间的研究,我没有答案。

temp.df<-subset(spread.df, x<5 & x>1 & y>1 & y<5)

wireframe((temp.df$z ~ temp.df$x + temp.df$y),
  scales=list(arrows=F), 
  screen = list(z = 40,x= -60) 
)

如果我运行这段代码,x 和 y 轴是从 2 到 4,其间只有一个增量,即 3。这使得图形的分辨率非常低。有没有办法在不操纵我的原始数据集的情况下提高分辨率?通过更高的分辨率,我的意思是细分线框的表面。

谢谢!

4

1 回答 1

3

好的,这里是你如何用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) 
)

在此处输入图像描述

于 2013-12-02T18:16:32.060 回答