Hi, I am trying to plot densities given on a two dimensional grid. My data is in the an external file, and is arranged in three columns: x, y, density how may i get a plot of this? i would like to get (1) a three dimensional plot and (2) a color coded two dimensional plot. I have tried using image(x, y, density) but i am asked to put the data in ascending order. i am not sure how i may put grid points in an ascending order. I would also like to know if i could use any other function, other than image. thank you in advance. -- saurav
On 13 Jan 2003 at 18:22, Saurav Pathak wrote:> Hi, > > I am trying to plot densities given on a two dimensional grid. My > data is in the an external file, and is arranged in three columns: > x, y, density > > how may i get a plot of this? i would like to get (1) a three > dimensional plot and (2) a color coded two dimensional plot. > > I have tried using > > image(x, y, density)You have here x, y, density vectors of the same length, which is not what image expects. The help page for image tells you that x and y should be vectors (each in ascending order), and z a matrix with dimensions length(x) and length(y). See the example on the help page for image. If your data are not a rectangular grid, you must probably interpolate before you can use image. Kjetil Halvorsen> > but i am asked to put the data in ascending order. i am not sure > how i may put grid points in an ascending order. > > I would also like to know if i could use any other function, other > than image. > > thank you in advance. > > -- > saurav > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-help
On Monday 13 January 2003 05:22 pm, Saurav Pathak wrote:> Hi, > > I am trying to plot densities given on a two dimensional grid. My > data is in the an external file, and is arranged in three columns: > x, y, density > > how may i get a plot of this? i would like to get (1) a three > dimensional plot and (2) a color coded two dimensional plot.persp() for (1) and image() or filled.contour() for (2). Both need the density in the form of a matrix, as described in their respective help pages. Alternately, you could you the 3D functions in the lattice package: library(lattice) levelplot(density ~ x * y) for (2). wireframe(density ~ x * y) will give you something similar to persp(), but it will be much slower.> > I have tried using > > image(x, y, density) > > but i am asked to put the data in ascending order. i am not sure > how i may put grid points in an ascending order. > > I would also like to know if i could use any other function, other > than image. > > thank you in advance.
Hallo On 13 Jan 2003 at 18:22, Saurav Pathak wrote:> Hi, > > I am trying to plot densities given on a two dimensional grid. My > data is in the an external file, and is arranged in three columns: x, > y, density > > how may i get a plot of this? i would like to get (1) a three > dimensional plot and (2) a color coded two dimensional plot. > > I have tried using >try to use library(akima) ddd<interp(x,y,density,duplicate="median") image(ddd) or persp(ddd)> image(x, y, density) > > but i am asked to put the data in ascending order. i am not sure how > i may put grid points in an ascending order. > > I would also like to know if i could use any other function, other > than image. > > thank you in advance. > > -- > saurav > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > http://www.stat.math.ethz.ch/mailman/listinfo/r-helpHope it helps Cheers Petr petr.pikal at precheza.cz p.pik at volny.cz
Thanks to all who have provided me with valuable suggestions. I am forging ahead now, and am beginning to enjoy R. Thanks, Saurav Thus spake Saurav Pathak: + Hi, + + I am trying to plot densities given on a two dimensional grid. My + data is in the an external file, and is arranged in three columns: + x, y, density + + how may i get a plot of this? i would like to get (1) a three + dimensional plot and (2) a color coded two dimensional plot. + + I have tried using + + image(x, y, density) + + but i am asked to put the data in ascending order. i am not sure + how i may put grid points in an ascending order. + + I would also like to know if i could use any other function, other + than image. + + thank you in advance. + + -- + saurav + + ______________________________________________ + R-help at stat.math.ethz.ch mailing list + http://www.stat.math.ethz.ch/mailman/listinfo/r-help