简体   繁体   English

R点阵线框:如何提高3D图形的分辨率

[英]R lattice wireframe: how to increase the resolution of 3D graph

I have a question which I don't have the answer to after a while of research. 经过一段时间的研究后,我有一个问题,我没有答案。

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) 
)

If I run this code, the x and y axes are from 2 to 4 with only one increment in between, which is 3. This makes the graph very low res. 如果我运行此代码,x和y轴从2到4,中间只有一个增量,即3。这使得图形非常低。 Is there a way to bump the resolution without manipulating my original data set? 有没有办法在不操纵原始数据集的情况下提高分辨率? By higher resolution, I mean subdividing the surface of the wireframe. 通过更高的分辨率,我的意思是细分线框的表面。

Thank you! 谢谢!

OK here is how you can interpolate the surface with the akima package. 好的,这里是你如何用akima包插入表面。 By default it will give you a 40x40 grid, based on the existing surface: 默认情况下,它会根据现有表面为您提供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) 
)

在此输入图像描述

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

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