Question: I have matrix (n x3) that represents discrete data. Each row of matrix is 3-D point (x,y,z). I would like to get contour map (z value) at two dimension (x,y). How can I use related contour function to do this job? I am not sure if I clarify this question. For example, we can get point (x,y) at 2 dimension according to first two columns of matrix. Then I want to connect same value z=(x,y). Thanks! zhang The data file looks like this: X y z 4 0.33 0.99 4 0.5 1.2 5 0.66 1.2 5 0.7 1.5 6 2 1.2 ?
Thomas W Blackwell
2003-Dec-21 19:15 UTC
[R] [Mailman] question: contour plot for discrete data
Dear L Z - Before using contour() one needs to interpolate the z values to all points in a rectangular grid. 2D interpolation is not trivial. The package KernSmooth (case-sensitive) will do this for a density estimate but not, apparently, when z values are given. Perhaps packages splines or mclust will do this, although I haven't checked. More likely, the functions surf.ls(), surf.gls() from package spatial. Other users who are familiar with maps and geographic information systems (GIS) packages for R may have much better ideas for you than I know about. I've never had occasion to use any of this. - tom blackwell - u michigan medical school - ann arbor - On Fri, 19 Dec 2003, L Z wrote:> Question: > I have matrix (n x3) that represents discrete data. > Each row of matrix is 3-D point (x,y,z). I would like > to get contour map (z value) at two dimension > (x,y). How can I use related contour function to do > this job? > I am not sure if I clarify this question. For example, > we can get point (x,y) > at 2 dimension according to first two columns of > matrix. Then I want to connect > same value z=(x,y). Thanks! > zhang > > The data file looks like this: > X y z > 4 0.33 0.99 > 4 0.5 1.2 > 5 0.66 1.2 > 5 0.7 1.5 > 6 2 1.2 > ? >
Hi library(akima) function contour(interp(x,y,z)) is one possibility Cheers Petr On 19 Jan 2058 at 48:211, L Z wrote:> Question: > I have matrix (n x3) that represents discrete data. > Each row of matrix is 3-D point (x,y,z). I would like > to get contour map (z value) at two dimension > (x,y). How can I use related contour function to do > this job? > I am not sure if I clarify this question. For example, > we can get point (x,y) > at 2 dimension according to first two columns of > matrix. Then I want to connect > same value z=(x,y). Thanks! > zhang > > The data file looks like this: > X y z > 4 0.33 0.99 > 4 0.5 1.2 > 5 0.66 1.2 > 5 0.7 1.5 > 6 2 1.2 > ? > > ______________________________________________ > R-help at stat.math.ethz.ch mailing list > https://www.stat.math.ethz.ch/mailman/listinfo/r-helpPetr Pikal petr.pikal at precheza.cz