22
$\begingroup$

With the command ListPlot[data,Joined -> True] I can visually connect adjacent data points in the array with lines. However, this option appears to be missing in ListPointPlot3D? Is there some manner with which to join with to join (with a line) adjacent three-dimensional points? There will be a large number of points in my data structure, and I'd really like to keep the standard output format of ListPointPlot3D.

$\endgroup$
3
  • $\begingroup$ 'Adjacent` can have a rather fuzzy meaning. Are the points on one surface or segregated to some fixed number of surfaces? If so, you can just use ListPlot3D. $\endgroup$
    – ciao
    Commented Jan 24, 2014 at 5:15
  • 2
    $\begingroup$ @rasher Adjacent just means that the elements in the array are next to one another, e.g. {A,B,C,D,...} would have "A" next to "B", "B" is next to both "A" and "C", and so forth. $\endgroup$
    – 110110
    Commented Jan 24, 2014 at 5:17
  • 2
    $\begingroup$ @rasher The problem with ListPlot3D is that I don't want a surface, I just want a "chain" of connected points like this: mars.cs.umn.edu/projects/current/VisionAidedINS_MSCKF/… $\endgroup$
    – 110110
    Commented Jan 24, 2014 at 5:26

3 Answers 3

22
$\begingroup$
pts = RandomReal[{0, 1}, {19, 3}]; 
Show[ListPointPlot3D@pts, Graphics3D@Line@pts]

Mathematica graphics

Edit:

Something slightly more useful as an example:

data = RandomFunction[RandomWalkProcess[0.3], {0, 10^2}, 3];
pts = Transpose@data["States"];
Show[ListPointPlot3D@#, Graphics3D@Line@#] &@pts

Mathematica graphics

$\endgroup$
4
  • $\begingroup$ Very very nice. $\endgroup$
    – 110110
    Commented Jan 24, 2014 at 5:35
  • $\begingroup$ Why not Graphics3D[{Point@pkt, Line@pkt}]? Because of axes etc? $\endgroup$
    – Kuba
    Commented Jan 24, 2014 at 8:09
  • $\begingroup$ @Kuba The OP said "I'd really like to keep the standard output format of ListPointPlot3D", and I think he better way to keep the format of ListPointPlot3D[] is by using it :) $\endgroup$ Commented Jan 24, 2014 at 11:13
  • $\begingroup$ oh, right :) +1 :P $\endgroup$
    – Kuba
    Commented Jan 24, 2014 at 11:21
23
$\begingroup$

One can use ListPointPlot3D and then replace Point with Line. By this way, the plot can enjoy options of ListPointPlot3D:

ListPointPlot3D[...]/. Point[a___] :> {Thick, Line[a]}
$\endgroup$
1
  • $\begingroup$ This is great!! I think your answer is better than Dr. belisarius. belisarius's method join points with black lines. However, if there are groups of curve data, your method gives consistent color in each curve, fantastic! $\endgroup$
    – matheorem
    Commented Apr 1, 2016 at 15:08
4
$\begingroup$

I was in the same situation, and what worked really well for me was this answer from a different question.

I'll start off with the random data generated by Dr belisarius:

data = RandomFunction[RandomWalkProcess[0.3], {0, 10^2}, 3];
pts = Transpose@data["States"];
ListPointPlot3D[pts, ColorFunction -> "SouthwestColors"]

enter image description here

pts is a list of points {{x1,y1,z1},{x2,y2,z2},...}, we convert this to a list of the form {{t1,{x1,y1,z1}},{t2,{x2,y2,z2}},...}:

ptsT = Transpose[{Range[1, Length@pts], pts}]

We then create a function to interpolate ptsT, which we can plot using ParametericPlot3D:

func = Interpolation[ptsT];
ParametricPlot3D[func[\[Tau]], {\[Tau], 1, Length@pts}, 
 ColorFunction -> 
  Function[{x, y, z, t}, ColorData["SouthwestColors"][z]]]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.