MathGroup Archive 2007

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

Search the Archive

Re: Plot in a Do loop does nothing

  • To: mathgroup at smc.vnet.net
  • Subject: [mg78284] Re: Plot in a Do loop does nothing
  • From: Bill Rowe <readnewsciv at sbcglobal.net>
  • Date: Wed, 27 Jun 2007 05:36:23 -0400 (EDT)

On 6/26/07 at 4:34 AM, pystab at hotmail.com (Tim Birks) wrote:

>Can anyone please explain why the line: Do[Plot[Sin[x], {x, 0,
>2*n*Pi}], {n, 1, 2}]

>does nothing in Mathematica 6? Or, how else I can produce such a
>series of related plots? It worked fine in Mathematica 5!

Due to the difference in the way graphics are done in version 6
and version 5, you need to explicitly print the graphics in a Do
loop, i.e.,

Do[Print@Plot[Sin[x], {x, 0, 2*n*Pi}], {n, 1, 2}]

Alternatively, you could use Table to create a list of plots, i.e.,

Table[Plot[Sin[x], {x, 0, 2*n*Pi}], {n, 1, 2}]

and if you want to get rid of the curly brackets you could use
one of TableForm, GraphicsGrid, Grid, GraphicsColumn or
GraphicsRow to display the list as you want.
--
To reply via email subtract one hundred and four


  • Prev by Date: Re: Maximize with Integer constraints
  • Next by Date: Fwd: Just one "1" in a list
  • Previous by thread: Re: Plot in a Do loop does nothing
  • Next by thread: Re: Plot in a Do loop does nothing