MathGroup Archive 2009

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

Search the Archive

Re: Online Graphic Output

On Mar 21, 6:20 am, felixheiner <werner.lech... at> wrote:
> Normally Mathematica uses data sets that are collected
> before plotting. I receive a data stream from internet
> and would like to display these data points immediately.
> ... Could anybody help out ?

You might be able to use Dynamic.  It's hard to say for
sure without knowing the nature of your data, but here's
something similar that I did to display the chaos game

numPoints = 5000;
f1[{x_, y_}] := {x, y}/2;
f2[{x_, y_}] := {x, y}/2 + {1/2, 0};
f3[{x_, y_}] := {x, y}/2 + {1/4, Sqrt[3]/4};
initPoint = RandomReal[{0, 1}, {2}];
pointList = Table[initPoint, {numPoints}];
 PlotRange -> {{0, 1}, {0, Sqrt[3]/2}}]

This creates a Graphics object that will be dynamically
updated as pointList is updated.  The action starts
when you execute the following.

Do[pointList[[i + 1]] =
  RandomChoice[{f1, f2, f3}][pointList[[i]]];
    Pause[0.02], {i, 1, numPoints - 1}]

One point I'd like to make: I would rarely create a long
list like this by initializing an array and writing term
by term.  Built in tools like NestList or Reap/Sow are
typically much more efficient.  They build the whole list
at once, though, so they are not well suited for generation
of dynamic data like this.  Join, Append, and AppendTo are
also poor choices, since your will notice a slow down as
your data grows.  The above requires an upper bound on
the size of your data, which you might or might not have.

Mark McClure

  • Prev by Date: Re: Orthogonazlie with Method->"Householder"
  • Next by Date: Re: ParametricPlot problem
  • Previous by thread: Re: Online Graphic Output
  • Next by thread: Online Graphic Output