       Re: ListLinePlot[] inside a loop

• To: mathgroup at smc.vnet.net
• Subject: [mg82382] Re: ListLinePlot[] inside a loop
• From: Szabolcs Horvát <szhorvat at gmail.com>
• Date: Fri, 19 Oct 2007 04:52:59 -0400 (EDT)
• References: <ff789h\$nrs\$1@smc.vnet.net>

```Luiz Melo wrote:
> Hi mathgroup,
>
> Why is the plot of a list not displayed when ListLinePlot[] is used inside a Do
> loop (Mathematica 6.0)?
> For instance, suppose we want to produce the graphics of Sin[i*x] as a function
> of x, each time i is iterated from 1 to 3 (in steps of 1). I naively tryed:
>
> Do[ListLinePlot[Table[{x, Sin[i*x Degree]}, {x, 0, 360}],
>    PlotRange -> {{0, 360}, {-1.1, 1.1}}], {i, 1, 3}];

In Mathematica 6, graphics are like any other value.  Instead of being
drawn as a side effect, they are simply /returned/ by plotting
functions.  Do[] always returns Null, so replace it with Table and
remove the ; from the end.  You might want to wrap the output in Column[] :

Table[ListLinePlot[Table[{x, Sin[i*x Degree]}, {x, 0, 360}],
PlotRange -> {{0, 360}, {-1.1, 1.1}}], {i, 1, 3}] // Column

> The specifications "For[]" and "While[]" don't work either.

While[] and For[] are better avoided in Mathematica.  If you really
insist on using such functions, then try

Do[Print@ListLinePlot[Table[{x, Sin[i*x Degree]}, {x, 0, 360}],
PlotRange -> {{0, 360}, {-1.1, 1.1}}], {i, 1, 3}]

--
Szabolcs

```

• Prev by Date: Re: Finds strings in a list that begin with "A"
• Next by Date: Re: ListLinePlot[] inside a loop
• Previous by thread: Re: ListLinePlot[] inside a loop
• Next by thread: Re: ListLinePlot[] inside a loop