Re: processing {x,y,z} data

*To*: mathgroup at smc.vnet.net*Subject*: [mg13111] Re: [mg13060] processing {x,y,z} data*From*: David Withoff <withoff>*Date*: Tue, 7 Jul 1998 03:44:15 -0400*Sender*: owner-wri-mathgroup at wolfram.com

> I am in need of efficiently processing lists of {x,y,z} data and am > finding severe roadblocks with almost every built-in function I can > think of. If anyone has figured work arounds for the following > behaviors, I would appreciate your input. > > 1-Interpolation. It wants lists of data with a square number of > points. This means it can interpolate a 100 element list(10x10), but > not a 90 element list(9x10). I don't want to throw away or pad data. > > 2-ListPlot3D. Only wants an array of z values and plots them versus > the array element number. This means that unevenly spaced data can't > be plotted. I want to put in the {x,y,z} data points so that the axes > are correct. > > 3-ListSurfacePlot3D. The ViewPoint option is broken. No matter what > viewpoint I select, it uses one that is more or less equivalent to > ViewPoint->{whatever,whatever,0}. I can't get the top-down viewpoint. > > 4-ScatterPlot3D-ViewPoint option is broken as in item #3. > > 5-ContourPlot-Only wants an array of heights. I can't give it the > {x,y,z} coordinates. This means that unevenly spaced data can't be > plotted nor will the values on the axes be correct. > > The most severe limitation is with #1, the Interpolation function. > Could I interpolate my data, I could convert it to any format required. > > Thanks for your help--Sean Ross > > P.S. I am using version 3.0.1 on a Win 95 pentium. 1 - Interpolation does not require a square number of points. A 9x10 grid will work fine. Interpolation does require a grid, with all of the points filled in, but the grid does not have to be square, and the lines through the grid don't even need to be evenly spaced. The grid can also represent a non-rectangular coordinate system, such as cylindrical coordinates. If you have an example where a 9x10 grid doesn't seem to work, I recommend sending it to Wolfram Research tech support so that they can take a look at it. 2 - If data represents an array of {x,y,z} values on a 9x10 grid, you can pick out an array of z values suitable for ListPlot3D using Sort, Map, and Partition, as in data = Flatten[Table[{x, y, Sin[x] + y}, {x, 9}, {y, 10}], 1] zvalues = Partition[Map[Last, Sort[data]], 10] ListPlot3D[zvalues] Note that, unlike Interpolation, ListPlot3D does require the grid lines to be evenly-spaced and perpendicular. If they aren't, but are still on a grid, you could use Interpolation and resample onto an even grid. 3 and 4 - If you have examples where ViewPoint doesn't seem to work, you could send those to Wolfram Research technical support too. I don't know of any examples where ViewPoint doesn't work. For example, the following worked fine when I tried it, and gave view points almost directly above the surface: data = Table[{x, y, Sin[x] + y}, {x, 9}, {y, 10}] Needs["Graphics`Graphics3D`"] ListSurfacePlot3D[data, ViewPoint -> {1, -1, 10}] ScatterPlot3D[Flatten[data, 1], ViewPoint -> {1, -1, 10}] 5) The comments in (2) for ListPlot3D also apply to ListContourPlot. You might also look at the ExtendGraphics packages, which are available on MathSource, and are described in "Mathematica Graphics: Techniques and Applications" by Tom Wickham-Jones. These packages include facilities for contouring data that don't fall on any sort of grid. Dave Withoff Wolfram Research