[R] [Mailman] question: contour plot for discrete data

Thomas W Blackwell tblackw at umich.edu
Sun Dec 21 20:15:53 CET 2003


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
> ?
>




More information about the R-help mailing list