MathGroup Archive 1996

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: surface plots from irregularly spaced data (scatter) points

  • To: mathgroup at
  • Subject: [mg4409] Re: surface plots from irregularly spaced data (scatter) points
  • From: fschwab at (Fred Schwab)
  • Date: Fri, 19 Jul 1996 04:36:51 -0400
  • Organization: National Radio Astronomy Observatory
  • Sender: owner-wri-mathgroup at

Re: Surface plots from irregularly spaced data

    Here's a quick and dirty approach that I sometimes use, which is
based on a brute-force implementation of Shepard's interpolation
formula [1].  The suitability, with particular emphasis on graphics
applications, of this and various other scattered-data interpolation
methods is discussed in Reference [2].  I chose Shepard's method
mainly on the basis of its simplicity and because it doesn't tend to
go "wild" in sparsely sampled regions.  In the code below, I've
selected a weighting exponent alpha=4; see Reference [1] for
illustrations of the effect of varying this parameter.


f[x_,y_]:=Sin[x y]


    Sum[list[[l,3]] w[[l]],{l,m}]/Sum[w[[l]],{l,m}]]



    Here, I first generate a plot of f(x,y)=sin(x y) over the
rectangle 0<x<3, 0<y<3, as in the example on page 155 of the
Mathematica book (2nd Ed.).  Then I generate 500 data points randomly
distributed over the same domain, sample f at these points, construct
an interpolating function, fi, and call Plot3D to make a plot of this
interpolant.  Finally, with ScatterPlot3D I show the a scatter plot of
the randomly generated data and then superimpose it upon the 3-D
perspective plot of the interpolant.

    I must, of necessity, use "Compile" and "Evaluate" before calling
a plotting function, otherwise this would run too slowly.  Still, this
brute-force method is too time-consuming for very large n (n>1000, say).  
Probably the best approach for large-scale applications would be to
call, say, a Fortran- or C-coded mathlink application designed along
the lines of the codes in References [4,5] - which are described in
Reference [3] - in order to generate a regularly spaced table of data,
and to follow that with a call to ListPlot3D.


[1] W. J. Gordon and J. A. Wixom, ``Shepard's method of `metric interpolation'
    to bivariate and multivariate interpolation'', Mathematics of
    Computation, 32 (1978) 253-264.
[2] R. Franke, ``Scattered data interpolation: tests of some methods'',
    Mathematics of Computation, 38 (1982) 181-200.
[3] R. J. Renka, ``Multivariate interpolation of large sets of scattered
    data'', ACM Transactions on Mathematical Software, 14 (1988) 139-148.
[4] ___________, ``Algorithm 660: QSHEP2D: Quadratic Shepard method for
   bivariate interpolation of scattered data'', ibid., 149-150.
[5] ___________, ``Algorithm 661: QSHEP3D: Quadratic Shepard method for
   trivariate interpolation of scattered data'', ibid., 151-152.

                                      - Fred Schwab (fschwab at
                                        National Radio Astronomy Observatory
                                        Charlottesville, VA


  • Prev by Date: Re: Problem with discontinuity in NDSolve[]
  • Next by Date: Re: Plot and colors
  • Previous by thread: Re: surface plots from irregularly spaced data (scatter) points
  • Next by thread: Re: Mma on PowerMac 8100 vs. Mma on PowerMac 9500