Sign up ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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, Pickett, belisarius has settled, 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

1 Answer 1

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.