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

MathGroup Archive 2009

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

Search the Archive

Online Graphic Output

  • To: mathgroup at smc.vnet.net
  • Subject: [mg97884] Online Graphic Output
  • From: Mark McClure <mcmcclur at unca.edu>
  • Date: Tue, 24 Mar 2009 05:34:36 -0500 (EST)

On Mon, Mar 23, 2009 at 5:43 AM, <werner.lechner at t-online.de> wrote:

>     Thank You for your advice. But I could not solve my problem.
>     Therefore I reduced the problem to a simple code example:
>
>     Do[{ x = Random[], y = Random[], p = Point[{x, y}],
>         Graphics[{PointSize[0.1], p}, GridLines -> Automatic,
>         Frame -> True, PlotRange -> { {-1, 1}, {-1, 1}}]} ,
>       {n, 1, 5}]
>
>     I would like to receive a single graphic with 5 points plotted.
>     The statements within the Do loop show nothing, not even a
>     error message with the Mathematica version 7.


The output of Do is always Null.  Thus, the code generates no
graphic.  You can examine the values of x, y, and p to see that
something has happened.  Also, you're writing over the value
of p every time through anyway so the final graphic has only
one point.  How about

points = {};
Do[x = RandomReal[{-1, 1}];
  y = RandomReal[{-1, 1}];
  AppendTo[points, {x, y}];
  p = Point[points], {5}];
Graphics[{PointSize[0.1], p},
 GridLines -> Automatic, Frame -> True,
 PlotRange -> {{-1, 1}, {-1, 1}}]

My understanding from the MathGroup discussion was that you
would like the images to be updated dynamically.  You can
achieve this effect as follows.

p = {};
points = {};
Graphics[{PointSize[0.1], Dynamic[p]},
 GridLines -> Automatic, Frame -> True,
 PlotRange -> {{-1, 1}, {-1, 1}}]

Do[x = RandomReal[{-1, 1}];
  y = RandomReal[{-1, 1}];
  AppendTo[points, {x, y}];
  p = Point[points]; Pause[1],
  {5}];

Note that that is two separate cells.  The first sets up the graph
with a dynamic variable and the second adjusts that variable.
As I mentioned in my MathGroup post, I don't really like
AppendTo for this purpose.  The list in this example is short
though and the AppendTo is very simple.

Hope that helps,
Mark McClure



  • Prev by Date: Re: Wavelet Denoising using Wavelet Explorer package
  • Next by Date: Re: Online Graphic Output
  • Previous by thread: Re: Online Graphic Output
  • Next by thread: Re: Online Graphic Output