MathGroup Archive 2012

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

Search the Archive

Re: Do Plot

It will work in versions before 6 but not later. Do only "does" but 
produces no output. In versions of Mathematica before 6, the actual 
picture produced by Plot was a "side-effect", but since version 6 the 
picture is actually output and since Do returns no output you get no 

There are two solutions.

1. The bad solution. Make it work just as before version 6. Print works 
by "side-effect" so just insert print into your code like this:

Do[Print[Plot[x^2 + c, {x, -2, 2}]], {c, -1, 1, 0.2}]

The reason why this is bad is because since your pictures are not output 
you can't do anything with them.

2. The second approach is to forget Do and use something that produces 
output, like Table. Thus

graphs = Table[Plot[x^2 + c, {x, -2, 2}], {c, -1, 1, 0.2}];

will make a list containing your pictures as Mathematica objects. You 
can now use them in all sorts of ways,e.g


GraphicsGrid[{graphs[[1 ;; 5]]}]

GraphicsGrid[Transpose[{graphs[[1 ;; 5]]}]]

and so on.

Andrzej Kozlowski

On 16 Dec 2012, at 11:05, dwarnold45 at wrote:

> Should this command work in Mathematica 9?
> Do[Plot[x^2 + c, {x, -2, 2}], {c, -1, 1, 0.2}]
> Not working on my Macbook Pro, Snow Leopard 10.6.8.
> David.

  • Prev by Date: Re: Do Plot
  • Next by Date: How to use FindMaximum with a parameter passed to NDSolve??
  • Previous by thread: Re: Do Plot
  • Next by thread: Re: Do Plot