Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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

share|improve this question

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.

Previously (possible duplicate): Difference in Plot when using Evaluate vs when not using Evaluate – Rahul May 23 '14 at 18:07
up vote 3 down vote accepted

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

share|improve this answer

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