You could try using levelplot from the lattice package: library(lattice) levelplot(mcpvalue~x+y)
failing that, interpolate them to a grid using akima or fields then display with image L On 8 Nov 2007, at 18:13, Duncan Murdoch wrote: > On 11/8/2007 11:51 AM, zhijie zhang wrote: >> Dear friends, >> My dataset is like the following: >> x y mcpvalue >> 0.4603578 0.6247629 1.001 >> 0.4603715 0.6247788 1.001 >> 0.4603852 0.6247948 1.001 >> 0.4110561 0.5664841 0.995 >> The x and y variables are unsorted. >> I use the function image(x,y,mcpvalue) to generate a plot, but >> the error >> is that "increasing 'x' and 'y' values are expected". So i use >> image(x=seq(min(x),max(x)), y=seq(min(y),max(y)),z=as.matrix >> (result$mcpvalue)) >> to do it again, but there is still an error "dimensions of z are not >> length(x)(-1) times length(y)(-1)". >> Anybody can show me how to use the image() correctly with the >> original x/y >> unsorted? > > You can't, it doesn't know how to handle that kind of data. > > image() is designed to display a matrix of values. The x and y values > tell it where to put the rows and columns of the matrix. > > You have a set of points. You need to fit a surface to them, evaluate > the surface on a grid, and pass that to image(). > > There are many ways to do that; the akima package has the interp() > function for instance. > > Duncan Murdoch > > ______________________________________________ > R-help@r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-help > PLEASE do read the posting guide http://www.R-project.org/posting- > guide.html > and provide commented, minimal, self-contained, reproducible code. ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.