| Author |
Comment/Response |
Forum Moderator
email me
 |
09/30/99 06:32am
>I hope someonw can help me. >I am trying to plot points in 3D space of varying sizes. (These are specific points and sizes that I provide).
>I have put the data in an n x 4 matix (we'll call it 'sample' here) of the form:
>
>sample =
>{{1, 1, 1, 1},
>{1, 2, 3, 3},
>{3, 4, 5, 2},
>{1, 2, 5, 3},
>. . . . (and so on for thousands of lines)
>
>I would like to extract the first 3 terms of each line as the x,y,z coordinates of the points and last term of each line as the size (using the AbsolutePointSize command).
>What I came up with is the following command''
>
>Show [ Graphics3D [{ AbsolutePointSize [ Part [ sample, 4]], Point [ Part [ sample, { 1, 2, 3 }]]}]]
>
>I know something is wrong with the Part statements cuz it's extract the whole line, instead of the parts of each line. Also, I don't know that if I do get the Part commands right if it'll work. Should I be using the ScatterPlot3D command instead?
>(Sorry if this sounds silly or easy, but this is the FIRST time I have ever used Mathematica)
>Thanks,
>Tony
>UCLA
>Dept. of OBEE
=========
You are not far off. Your code does not quite take apart the ''points'' in your data:
In[7]:=sample =
{{1, 1, 1, 1},
{1, 2, 3, 3},
{3, 4, 5, 2},
{1, 2, 5, 3}}
Out[7]= {{1,1,1,1},{1,2,3,3},{3,4,5,2},{1,2,5,3}}
In[8]:= { AbsolutePointSize [ Part [ sample, 4]], Point
[ Part [ sample, { 1, 2, 3 }]]}
Out[8]={AbsolutePointSize[{1,2,5,3}],Point[{{1,1,1,1},{1,2,3,3},{3,4,5,2}}]}
However, if you ''go down a level'', you can get at the coordinates. Here is an example using the firs element of sample:
In[9]:={ AbsolutePointSize [ Part [ sample,1, 4]], Point
[ Part [ sample,1, { 1, 2, 3 }]]}
Out[9]= {AbsolutePointSize[1],Point[{1,1,1}]}
You could use table to build such an expression for each of the elements of sample:
In[10]:=
samplePoints = Table[{ AbsolutePointSize [ Part [ sample,i, 4]], Point
[ Part [ sample,i, { 1, 2, 3 }]]}, {i, 1, Length[sample]}]
Out[10]=
{{AbsolutePointSize[1],Point[{1,1,1}]},{AbsolutePointSize[3],Point[{1,2,3}]},{
AbsolutePointSize[2],Point[{3,4,5}]},{AbsolutePointSize[3],
Point[{1,2,5}]}}
Then the points can be displayed:
In[11]:=
Show[Graphics3D[samplePoints]]
Tom Zeller
Forum Moderator
URL: , |
|