0
$\begingroup$

This question already has an answer here:

When I plot the functions generated by NestList, I do not see differently coloured lines, which I do if I explicitly list them out.

I.e. with:

map[ x_, α_] := x^2 - α

the first Plot is monochrome (blue), the second one multicolour as expected:

Plot[NestList[map[#, 2] &, x, 5], {x, 0, 1}]

Mathematica graphics

Plot[{x, Nest[map[#, 2] &, x, 1], Nest[map[#, 2] &, x, 2], 
  Nest[map[#, 2] &, x, 3], Nest[map[#, 2] &, x, 4], 
  Nest[map[#, 2] &, x, 5]}, {x, 0, 1}]

Mathematica graphics

$\endgroup$

marked as duplicate by Kuba, Rahul, C. E., Dr. belisarius, RunnyKine May 23 '14 at 21:59

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

3
$\begingroup$

Arguments that are grouped together are styled the same. Because Plot has the attribute HoldAll the NestList is not evaluated so initially the number of arguments is counted as being just one. If you evaluate the argument on the other hand Plot sees four arguments. Plot uses one style for each argument it can "see". A simpler and instructive case of this is Mr.Wizard's sequence trick. For even more information about how this works you can read this Q&A.

map[ x_, α_] := x^2 - α
Plot[NestList[map[#, 2] &, x, 5], {x, 0, 1}]

enter image description here

Plot[Evaluate@NestList[map[#, 2] &, x, 5], {x, 0, 1}]
(* or *)
Plot[NestList[map[#, 2] &, x, 5], {x, 0, 1}, Evaluated -> True]

enter image description here

$\endgroup$

Not the answer you're looking for? Browse other questions tagged or ask your own question.