[R] Plotting irregular grid as image or persp

David Forrest drf5n at maplepark.com
Fri Aug 27 23:06:41 CEST 2004


Hi,
   I have an array of 2d node locations and an array triangles, and would
like to plot something like a image or persp.


An example of doing it with rgl is:

  library(ncdf)
  library(rgl)
  # wget http://www.maplepark.com/~drf5n/extras/teapot.nc
  teapot<-open.ncdf("teapot.nc")
  z<-get.var.ncdf(teapot,"tris")
  l<-get.var.ncdf(teapot,"locations")
  z<-as.vector(z)

 demo.teapot<-function(x=1){
  rgl.triangles(l[1,z],l[2,z],l[3,z])
  x<-readline("Hit any key to continue")
  rgl.pop()}

 demo.teapot() # produces a 3d rgl plot of the teapot

I wrote some rgl.* helper functions (
http://www.maplepark.com/~drf5n/cgi-bin/wiki.cgi?ElcircVisualization )
to drive rgl.points(), rgl.lines(), rgl.triangles(), rgl.quads() such that
I can call :

rgl.drf5n.polys(verts=l,conns=z) # plot points, wireframe, triangles,
# quads, depending on shape of conns)

but I'd really like to be able to plot an irregular grid with the
known triangles as specified colors, and I'm not sure
what would be the best package.

library(fields) extrapolates the image beyond the data
library(tripack) refits and plots its own data

What should I use? Suggestions?

Dave
-- 
 Dave Forrest
 drf at vims.edu                                    (804)684-7900w
 drf5n at maplepark.com                             (804)642-0662h
                                   http://maplepark.com/~drf5n/




More information about the R-help mailing list