Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
760 views
in Technique[技术] by (71.8m points)

simple R 3d interpolation / surface plot

I know this has been addressed many times, but i just cant seem to get my head around it. Hopefully someone can explain in a little more detail the steps i need to go through to achieve a surface plot in R.

I have a set of [x,y,z] points that i would like to turn into a surface plot. From reading around i can see that i will need to interpolate with Kring or something of the sort. I have absolutely no experience with 3d interpolation, so if someone could add how i would interpolate from a set of points in 3d space that would be a huge help.

Once i have that data set, i would like to create a surface plot from it. From what i understand i can use the interp() function to do so, but again i am not quite sure how.

If there is another post which you think has already answered this question, please direct me towards it.

thanks in advance!

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

Use the akima package. It has an interp function that's pretty straightforward.

library(akima)

x <- rnorm(20)
y <- rnorm(20)
z <- rnorm(20)

s <- interp(x,y,z)

Once you have the interpolated matrix you can do a variety of things.

One example is the image.plot function in the fields package.

image.plot(s)

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...