
Re: Do Plot
Posted:
Dec 17, 2012 2:54 AM


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 "sideeffect", but since version 6 the picture is actually output and since Do returns no output you get no picture.
There are two solutions.
1. The bad solution. Make it work just as before version 6. Print works by "sideeffect" 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
graphs[[5]]
GraphicsGrid[{graphs[[1 ;; 5]]}]
GraphicsGrid[Transpose[{graphs[[1 ;; 5]]}]]
and so on.
Andrzej Kozlowski
On 16 Dec 2012, at 11:05, dwarnold45@suddenlink.net 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. >

