Re: Online Graphic Output

• To: mathgroup at smc.vnet.net
• Subject: [mg97860] Re: Online Graphic Output
• From: "Sjoerd C. de Vries" <sjoerd.c.devries at gmail.com>
• Date: Tue, 24 Mar 2009 05:30:05 -0500 (EST)
• References: <gq2f1m\$efh\$1@smc.vnet.net>

```>
> 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.
>

A Do loop does not generate output. If you want to see results you
have to explicitly print them using Print[ ]. This works for values
and graphics alike. In your case, the loop doesn't generate a single
graph with 5 points, but 5 graphs with each a single point.

Furthermore, you are using commas to make a compound statement whereas
Mathematica requires a semicolon (;) for that purpose. Also, you are
probably confusing Do and Table. You would like to have a list of
points. A minimal modification of your code that works would then be:

Graphics[
Prepend[
Table[
x = Random[];
y = Random[];
Point[{x, y}],
{n, 1, 5}
], PointSize[0.1]
], GridLines -> Automatic, Frame -> True,  PlotRange -> {{-1, 1},
{-1, 1}}  ]

However, this is still pretty ugly. It can be written much more
elegantly:

Graphics[
{
PointSize[0.1],
Point[RandomReal[{0, 1}, {5, 2}]]
},
GridLines -> Automatic,
Frame -> True,
PlotRange -> {{-1, 1}, {-1, 1}}
]

This uses the fact that Point is listable, i.e. can work on a list of
points. It also uses the efficient RandomReal that is able to generate
multi-dimensional list of random numbers.

One final remark: The range of the random points and your choice for
PlotRange do not coincide. You should change PlotRange or the
RandomReal statement (in RandomReal[{-1, 1}, {5, 2}])

Cheers -- Sjoerd

On Mar 21, 12:20 pm, 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 I would like to display these data=
points immediately. A typical application of this kind could be a online c=
hart of changing prices. Although I am an experienced user of Mathematica 2=
-7 for many years, I do not know, how to program this application type. Cou=
ld anybody help out ?

```

• Prev by Date: Online Graphic Output
• Next by Date: Re: Incompatible units?
• Previous by thread: Online Graphic Output