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)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With