Services & Resources / Wolfram Forums / MathGroup Archive

MathGroup Archive 2001

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

Search the Archive

RE: ListPlot vs ListPlot3D

  • To: mathgroup at
  • Subject: [mg28935] RE: [mg28884] ListPlot vs ListPlot3D
  • From: "Wolf, Hartmut" <Hartmut.Wolf at>
  • Date: Sat, 19 May 2001 22:27:52 -0400 (EDT)
  • Sender: owner-wri-mathgroup at

Please see below:

> -----Original Message-----
> From:	Otto Linsuain [SMTP:linsuain+ at]
To: mathgroup at
> Sent:	Thursday, May 17, 2001 10:23 AM
> To:	mathgroup at
> Subject:	[mg28884] ListPlot vs ListPlot3D
> Dear Mathematica experts, I was wondering if there is a way of plotting
> a 3D graph using a rectangular array of z-values USING THE CORRESPONDING
> Here is what I mean:
> with a 2D plot, one can do:
> ListPlot[ {y1,y2,y3,.........yn} ]  and this will give a graph of the
> points
> {y1,1} ,{y2,2}, {y3,3},....{yn,n}, i.e. it will use the integers
> 1,2,3,...n as the x values.
> One can, however, write
> ListPlot[ { {x1,y1}, {x2,y2}, {x3,y3}, ... {xn,yn} }]
> and get a graph with user-specified values for x and y. 
> There doesn't seem to be an analogous thing for ListPlot3D. The values
> of x and y seem to be always {1,1}, {1,2},{2,1},{2,2},.......{n,n}
> Any ideas? Thanks in advance. Otto Linsuain.
[Hartmut Wolf]  


let me make up an example: Let's assume we have a regular, but not evenly
spaced grid for xy-values:

ygrid=Table[Pi/2*Sin[y],{y,-Pi/2,Pi/2, Pi/14}];

and z-values for say function Sin[x]*Cos[y] sampled at the grid.

tt=Apply[Sin[#1]Cos[#2]& ,xygrid,{2}]//N;

If we plot it with ListPlot3D we certainly get a distorted view


- SurfaceGraphics -

What we have to do, is to shift the integer grid of ListPlot3D to the real,
true xy-Grid of the problem. We cannot do that with SurfaceGraphics, so we
convert that to a Graphics3D object.



So far display is unchanged, but now we can put the points onto the real

gg2=gg1/.Polygon[points_] :>
      Polygon[points/. {x_,y_,z_} :> xgrid[[Round[x]]],

- Graphics3D -


- Graphics3D -

Compare that with


- SurfaceGraphics -

and we watch the same 3D-shape, however at different grids. So we have got
the "real" plot, sampled at our own regular, yet not-equally spaced grid by
only use of the original data. And the axes come out correctly too.

This method of transformation also may be used to get a more dense sampling
at regions of special interest (e.g. at rapid variation). The grid still has
to stay regular though.

-- Hartmut

  • Prev by Date: Re: Mathematica graphics/fonts and Tex
  • Next by Date: Re: Re: OOP in Mathematica
  • Previous by thread: Re: ListPlot vs ListPlot3D
  • Next by thread: 2001 Mathematica Developer Conference