简体   繁体   中英

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!

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)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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