MathGroup Archive 2003

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

Search the Archive

RE: help with 3D scatter plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg41874] RE: [mg41845] help with 3D scatter plot
  • From: "David Park" <djmp at earthlink.net>
  • Date: Sat, 7 Jun 2003 11:44:58 -0400 (EDT)
  • Sender: owner-wri-mathgroup at wolfram.com

Jay,

I'm going to leave the answer to your first question to those who can give a
better answer and address your second question.

What method is best for viewing a collection of 3D points is a good
question. Clearly the points get in each other's way and it is difficult to
extract the spatial structure. Here are some explorations and suggestions.
Maybe others will have better ideas.

One method might be to generate two stereoscopic pictures, but I lack the
ability to merge such images so will skip that.

Here is a set of sample data points.

points = Table[{x = Random[Real, {-2, 2}],
     y = Random[Real, {-2, 2}],
     Sqrt[Max[Random[Real, {3, 4}] - x^2 - y^2, 0]]},
    {200}];
Clear[x, y]

Needs["Graphics`Colors`"]

plot1 =
    Show[
      Graphics3D[{Red, AbsolutePointSize[4], Point /@ points}]
      ];

With RealTime3D you can rotate this and zoom in and out, which may be some
help.

<< RealTime3D`
Show[plot1]
<< Default3D`

You can easily draw the points and lines to the xy-plane with the following
routine.

linepoint[{x_, y_, z_}] := {Black, Line[{{x, y, 0}, {x, y, z}}], Red,
    Point[{x, y, z}]}

plot2 =
    Show[
      Graphics3D[{Red, AbsolutePointSize[4], linepoint /@ points}]
      ];

I'm not certain if the structure that the lines add compensates for the
clutter they also add.

Another technique is to project the points onto the back and bottom planes.

pointsxy = points /. {x_, y_, z_} -> {x, y, 0};
pointsxz = points /. {x_, y_, z_} -> {x, 2, z};
pointsyz = points /. {x_, y_, z_} -> {-2, y, z};

plot3 =
    Show[
      Graphics3D[
        {Point /@ pointsxy,
          Point /@ pointsxz,
          Point /@ pointsyz,
          Red, AbsolutePointSize[4], Point /@ points}],
      PlotRange -> All
      ];

That again seems to add more clutter than information.

So, I repair to my favorite device for simplification - an animation. We
will construct a slice of a given y (say) width and then move it through the
data, showing only the points within the slice. I make the slices continuely
overlap to provide continuity. Since we are showing points that are
approximately in one plane, drawing the vertical line now adds more
information than clutter. A blue polygon is drawn in the xy-plane that
defines the width of the slice. Here is the definition for one frame and
then the animation.

frame[dely_][yslice_] :=
  Module[{framepoints, x, y, z},
    framepoints = points /. {x_, y_, z_} /;
            ! (yslice - 2dely <= y <= yslice + 2dely) -> Sequence[];
    Show[
      Graphics3D[
        {Red, AbsolutePointSize[4], linepoint /@ framepoints,
          LightBlue,
          Polygon[{{-2, yslice - 2dely, 0}, {-2, yslice + 2dely, 0}, {2,
                yslice + 2dely, 0}, {2, yslice - 2dely, 0}}]}],
      PlotRange -> {{-2, 2}, {-2, 2}, {0, 2}},
      ViewPoint -> {2.982, -1.215, 1.040}]
    ]


Table[frame[0.1][y], {y, -2, 2, 0.1}];
SelectionMove[EvaluationNotebook[], All, GeneratedCell]
FrontEndTokenExecute["OpenCloseGroup"]; Pause[0.01];
FrontEndExecute[{FrontEnd`SelectionAnimate[200, AnimationDisplayTime -> 0.1,
      AnimationDirection -> ForwardBackward]}]


David Park
djmp at earthlink.net
http://home.earthlink.net/~djmp/



From: seferiad [mailto:seferiad at pacbell.net]
To: mathgroup at smc.vnet.net

Hello,
I have Mathematica 4 and have two questions.
1) I have a 3D scatter plot, and I would like to do a least squares fit to
the data, and display the R^2 value. Since the graph is 3D, the curve fit
should be a surface.  I don't think I can do this conveniently, has anyone
found a work around for this?

2) Also, it is difficult to visualize the location of the data in the plot,
with or without the grids.  I once saw another graph (it may have been Igor
software?) in which each of the data points were attached to lines that were
parallel to the z-axis and stopped at the x-y plane. This is a very nice
feature. Is there something equivalent in Mathematica to help improve with
being able to visualize the graph?  Thanks, Jay


  • Prev by Date: Re: Re: Re: A bug?......In[1]:= Sum[Cos[x], {x, 0, Infinity, Pi}]......Out[1]= 1/2
  • Next by Date: Compatibility with pen
  • Previous by thread: help with 3D scatter plot
  • Next by thread: Re: help with 3D scatter plot