MathGroup Archive 2007

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

Search the Archive

Re: ListPointPlot3D

  • To: mathgroup at smc.vnet.net
  • Subject: [mg83012] Re: ListPointPlot3D
  • From: Jean-Marc Gulliet <jeanmarc.gulliet at gmail.com>
  • Date: Wed, 7 Nov 2007 06:34:31 -0500 (EST)
  • Organization: The Open University, Milton Keynes, UK
  • References: <fgpa06$iu2$1@smc.vnet.net>

SkyW wrote:
> Hi,
> 
> I would like to use ListPointPlot3D to plot several points in two different colors (ex. blue and red). I have a Table with following format:
> 
> list0={{x1, y1, z1, h1}, {x2, y2, z2, h2}, ..., {xn, yn, zn, hn}}
> 
> x,y,z refers to the 3D coordinates and h takes value 0 or 1. I would like to plot all points with h value equal to 1 as red and all points with h value equal to 0 as blue .... how can I do it?

First, we make up some data to populate list0 in the required format.

list0 = Flatten[
    Table[{x, y, Sqrt[1 - x^2 - y^2], If[x y < 0, 0, 1]}, {x, -1, 1,
      0.05}, {y, -1, 1, 0.1}], 1];

Then, we create two lists that contain the coordinates of the points 
that must be drawn in red and in blue, respectively, and plot these two 
lists with the appropriate *PlotStyle*.

Module[{redpts = {}, bluepts = {}},
  If[#[[-1]] == 0, AppendTo[redpts, #[[1 ;; 3]]],
     AppendTo[bluepts, #[[1 ;; 3]]]] & /@ list0;
  ListPointPlot3D[{redpts, bluepts}, PlotStyle -> {Red, Blue}]
  ]

You can see the result at

http://homepages.nyu.edu/~jmg336/mathematica/listpointplot3d.pdf

Best regards,
-- 
Jean-Marc


  • Prev by Date: Re: Crash with simple plot command
  • Next by Date: FW: Problem with Manipulate. Problem Solved.
  • Previous by thread: Re: ListPointPlot3D
  • Next by thread: Re: ListPointPlot3D