I am trying to visualize 3-tuple points that are NOT in a grid, and x and y are NOT equally spaced. Thus I can not make a matrix as mostly required, nor can I meet the requirements of the lattice contourplot, which accepts vectors, but they have to be in a pretty restrictive form. (x,y must form a grid and be equally spaced...)
I don't care, whether the result is a 3d surface or a 2D contourplot. But in some way I'ld like to visualize a (probably interpolated) surface of my 3-tuples.
Data will look like this:
myX myY myZ
1 458 4 0.54
2 101 5 0.46
3 390 0 0.45
4 186 2 0.84
5 241 3 0.50
6 495 2 0.67
I have tried several plotting functions from graphics, rgl and lattice packages. I understand that the connecting of x,y pairs at arbitrary positions is everything but trivial - but is there any plotting function in any package, which can handle this? Or can I fill (interpolate) my data beforehand easily in order to have a full matrix? (I have fitted models visualized, but I want to see the raw data...)
Any help or hint is appreciated!
Cheers, Niko
I bit hard to understand the question, but I will try to show how one interpolates to a full matrix. I usually use the interp
function from the akima
package:
set.seed(1)
x <- runif(20)
y <- runif(20)
z <- x^3 + sin(y)
require(akima)
F <- interp(x,y,z)
image(F)
points(x,y)
Here's an example of extrapolation:
F <- interp(x,y,z, linear=FALSE, extrap=TRUE)
image(F)
points(x,y)