Services & Resources / Wolfram Forums / MathGroup Archive
-----

MathGroup Archive 2009

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

Search the Archive

Re: Online Graphic Output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97824] Re: Online Graphic Output
  • From: mark mcclure <mcmcclur at unca.edu>
  • Date: Sun, 22 Mar 2009 05:51:29 -0500 (EST)
  • References: <gq2f1m$efh$1@smc.vnet.net>

On Mar 21, 6:20 am, felixheiner <werner.lech... at t-online.de> 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
dynamically.

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}];
Graphics[Point[Dynamic[pointList]],
 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