Mathematica 9 is now available
Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Help Creating 3D List Line Plot

  • To: mathgroup at smc.vnet.net
  • Subject: [mg103729] Help Creating 3D List Line Plot
  • From: Aaron Bramson <aaronbramson at gmail.com>
  • Date: Sun, 4 Oct 2009 05:35:05 -0400 (EDT)
  • Reply-to: aaronbramson at gmail.com

Hello there,

I'm trying to plot the output of my simulations as lines in a 3D Plot but I
can't coerce Mathematica do manipulate the data to make this possible.  Each
experiment is conducted for 100 runs and they each go for different
durations of time.  Getting the individual points from the output csv is
easy enough:

MyData := Import["OutputFile1.csv"]
MyPoints := Table[List[MyData[[i, 1]], MyData[[i, 20]], MyData[[i, 30]]],
{i, Length[MyData]}]

where
-1 is the column with the run number
-20 is the column with the time step
-30 is the column for measure I want to see change over time across runs

This produces something of the form:
{{0, -8, 0}, {0, -7, .1}, {0, -6, .1}, {0, -5, .2}, {0, -4, .25}, {0, -3,
.3}, {0, -2, .37}, {0, -1, .4}, {0, 0, .38}, {1, -7, 0}, {1, -6, 0}, {1, -5,
0}, {1, -4, .2}, {1, -3, .2}, {1, -2, .3}, {1, -1, .33}, {1, 0, .36}, {2,
-3, 0}, {2, -2, .1}, {2, -1, .3}, {2, 0, .42}}

But to plot the data the way I want to see them I need something like:

dat01 := {{0, -8, 0}, {0, -7, .1}, {0, -6, .1}, {0, -5, .2}, {0, -4, .25},
{0, -3, .3}, {0, -2, .37}, {0, -1, .4}, {0, 0, .38}}
dat02 := {{1, -7, 0}, {1, -6, 0}, {1, -5, 0}, {1, -4, .2}, {1, -3, .2}, {1,
-2, .3}, {1, -1, .33}, {1, 0, .36}}
dat03 := {{2, -3, 0}, {2, -2, .1}, {2, -1, .3}, {2, 0, .42}}
Show[Graphics3D[Line[Partition[dat01, Length[dat01]]]],
 Graphics3D[Line[Partition[dat02, Length[dat02]]]],
 Graphics3D[Line[Partition[dat03, Length[dat03]]]]]

but in an iterative fashion that goes through MyPoints and collates the
points from run# as a separate list.  (I'll worry about opacity and color
gradients later and just hope it won't be a problem.)

The data are sorted by run number and time already, but as an added bonus
I'd really like to sort the runs by the z-value of the last element of the
list..which seems not difficult once I have the individual lists by run#.

None of this would be hard in Java but indices and constructors work
differently here.  What I came up with is:
List[For[i = 1, i < 101, i++, Select[TestData, TestData[[#, 1]] = i &]]] but
that gives me an error:

"Set::pspec: Part specification #1 is neither an integer nor a list of
integers. >>"  Apparently I can't refer to an element of the sublist as an
part specification.  TakeWhile had a similar problem...I can't figure out
how to tell Mathematica to take an element if its subelement satisfies a
property.

Of course there might be a much easier way to make a 3D List Line Plot but I
haven't found anything like it anywhere.  Any help you can provide would be
greatly appreciated.

Best,
Aaron


  • Prev by Date: Re: on passing arguments to a function, how to break a list into separate items during a call?
  • Next by Date: Re: on passing arguments to a function, how to break a
  • Previous by thread: Re: on passing arguments to a function, how to break a
  • Next by thread: Re: Help Creating 3D List Line Plot