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

Roger Bivand Roger.Bivand at nhh.no
Sun Dec 21 20:48:10 CET 2003


On Sun, 21 Dec 2003, Spencer Graves wrote:

> Have you considered "interp", as in the following example: 

in the akima package, just to make this plain.

> 
> XY <- expand.grid(x=1:11, y=1:11)
> XY$z <- XY$x+XY$y
> contour(interp(XY$x, XY$y, XY$z))
> 
> hope this helps.  spencer graves
> 
> Thomas W Blackwell wrote:
> 
> >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
> >>?
> >>
> >>    
> >>
> >
> >______________________________________________
> >R-help at stat.math.ethz.ch mailing list
> >https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> >  
> >
> 
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://www.stat.math.ethz.ch/mailman/listinfo/r-help
> 

-- 
Roger Bivand
Economic Geography Section, Department of Economics, Norwegian School of
Economics and Business Administration, Breiviksveien 40, N-5045 Bergen,
Norway. voice: +47 55 95 93 55; fax +47 55 95 93 93
e-mail: Roger.Bivand at nhh.no




More information about the R-help mailing list