r:3D表面图 [英] r : 3D surface plot
本文介绍了r:3D表面图的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
data.loess = loess(z~x*y,data =data.df)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
但是预测的z值与原始高度不一致.
像scatterplot3d
这样的函数仅给我分散的点,如何获得带有丘陵和山谷的表面?
解决方案
我不知道与原始高度不一致"是什么意思,但为什么不看:
persp(z)
x = seq(1,10,0.1); y = seq(1,10,0.1)
z= outer(x,y,"*")
data =data.frame(x=rep(x, times=91), y=rep(y, each=91), z=c(z) )
data.loess = loess(z~x*y,data =data)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
persp(z)
Assuming i have a dataframe of x , y , z wherein x any y are the coordinates and z is the height. How do I create a blanket of z over the x and y plane. I tried using the loess function to create a blanket
data.loess = loess(z~x*y,data =data.df)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
But the predicted z value is not in coherence with the original height.
Functions like scatterplot3d
gives me only the scattered dots,how do I get a surface with hills and valley?
解决方案
I have no idea what the phrase "not in coherence with original height" means, but why not look at:
persp(z)
x = seq(1,10,0.1); y = seq(1,10,0.1)
z= outer(x,y,"*")
data =data.frame(x=rep(x, times=91), y=rep(y, each=91), z=c(z) )
data.loess = loess(z~x*y,data =data)
data.fit = expand.grid(list(x = seq(min(x),max(x),0.1), y = seq(min(y),max(y),0.1)))
z = predict(data.loess, newdata =data.fit)
persp(z)
这篇关于r:3D表面图的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文