2
$\begingroup$

Let me just first say I am not actually trying to find a function for these set of data. All I am doing is joining the points to make a line.

Basically let's say I have some data, which I cleverly will call/name them as 'data' in Mathematica.

data:= {{1,0,0},{2,4,7},{2,6,7},{0,0,23}}

Now plotting them. (FYI, these data points are randomlly chosen)

ListPointPlot3D[data]

I should get a plot, but of course they are all disconnected. What I want to do is to join them. Unfortunately 'Joined -> True' does not exists in ListPointPlot3D, so I do not know how to join them

Any ideas?

EDIT

At the moment, I have a recursion. I will just show you the table

For instance

Table[x[n, t], {n, 1, 10}] 

prints out a list of 10 data points in 3D. It will not work with Graphics3D

EDIT

I will write out exactly what I have

x[1, t_] := {0,0,0};

A[t_] := {{1, -t, 1}, {t, 2, 0}, {0, 0,t}}

B[t_] := Inverse[A[t]];

x[n_Integer, t_] /; n > 0 := B[t].x[n - 1, t];

Table[x[n, t], {n, 1, 10}]

I want to plot the points and join them in a curve. If possilbe I would even like to manipulate the plot. The range for $t \in [0,1]$

Everything updated

$\endgroup$
5
  • 1
    $\begingroup$ You could just use Graphics3D[Line[data]]... $\endgroup$ Apr 7, 2013 at 18:12
  • $\begingroup$ What do you mean by "it will not work"? $\endgroup$
    – Jens
    Apr 7, 2013 at 18:36
  • $\begingroup$ It gives me an error. I will write out the code. $\endgroup$
    – Lemon
    Apr 9, 2013 at 0:04
  • $\begingroup$ Your definition for A[t_] is circular, it can't work ... and you have two defs for the same thing (A[t_]) $\endgroup$ Apr 9, 2013 at 0:26
  • $\begingroup$ I made a typo, one sec $\endgroup$
    – Lemon
    Apr 9, 2013 at 0:54

2 Answers 2

4
$\begingroup$
t := RandomReal[]
x[n_, t_] := Sin@t
data = Table[{n, #, x[n, #]} &[t], {n, 1, 10}];

Graphics3D[{Line@data, PointSize[Large], Point@data}, 
           PlotRange -> ({Min@# - 1, Max@# + 1} & /@ Transpose@data), Axes -> True]

enter image description here

Edit

Also something like this shall do

f = Interpolation[#, InterpolationOrder -> 1] & /@ Transpose@data;
Show[{ParametricPlot3D[Through[f[t]], {t, 1, Length@data}], 
      Graphics3D[{PointSize[Large], Point@data}]}]

enter image description here

$\endgroup$
4
  • $\begingroup$ OKay it connects them, but now I lose my points. I want to see the dots as well. You see what I mean? $\endgroup$
    – Lemon
    Apr 7, 2013 at 18:20
  • $\begingroup$ @jak See edit, please $\endgroup$ Apr 7, 2013 at 18:23
  • $\begingroup$ There is also one other problem, which I will edit in OP. $\endgroup$
    – Lemon
    Apr 7, 2013 at 18:26
  • $\begingroup$ see edit 10 chat $\endgroup$
    – Lemon
    Apr 9, 2013 at 0:10
3
$\begingroup$

Of course the Graphics3D approach in belisarius' answer is very general and should always work. But maybe you want to stick with ListPointPlot3D for some reason. Then you could use Show to combine the isolated points with a plot of the linear Interpolation between the points:

data = {{1, 0, 0}, {2, 4, 7}, {2, 6, 7}, {0, 0, 23}}

(* ==> {{1, 0, 0}, {2, 4, 7}, {2, 6, 7}, {0, 0, 23}} *)

iData = 
  Interpolation[Transpose[{Range[Length[#]], #} &@data], 
   InterpolationOrder -> 1];

Show[
 ListPointPlot3D[data], ParametricPlot3D[iData[t], {t, 1, 4}]
 ]

Show plots

It's worth mentioning here that Show always uses the options of the plot that comes first in the list, unless you specify additional options to Show (such as BoxRatios, if desired). You can also control the style of the points and curve separately using the usual options.

$\endgroup$
5
  • $\begingroup$ I always doubt when formatting a 3D list for feeding it into Interpolation. Sometimes I do like you did, and sometimes as in my answer here. Do you have any thoughts about what is the better way? $\endgroup$ Apr 7, 2013 at 20:25
  • $\begingroup$ I would have used your method, that's why I upvoted it... My answer was just motivated by the apparent "other problem" of the OP, which I don't understand yet. $\endgroup$
    – Jens
    Apr 7, 2013 at 20:48
  • $\begingroup$ As I understand it, he has {f1, f2, f3, ...} instead of {{x1,y1,f1} , {x2,y2,f2}, ...} $\endgroup$ Apr 7, 2013 at 20:50
  • $\begingroup$ @belisarius For what it's worth I would write: Interpolation @ MapIndexed[{#2, #} &, data] $\endgroup$
    – Mr.Wizard
    Apr 8, 2013 at 11:08
  • $\begingroup$ See edit 10 char $\endgroup$
    – Lemon
    Apr 9, 2013 at 0:06

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.