Plotting an array of functions in different colors

Join the discussion
Ask a follow-up here, or get your own question answered by working scientists, mathematicians and engineers — people, not an autocomplete.
Real named experts · corrections over time · the nuance an AI answer skips
2 replies · 2K views
Swamp Thing
Insights Author
Messages
1,062
Reaction score
819
TL;DR
A user-defined Mathematica function returns a list (array) of functions. How to plot them in different colors?
If we plot a list of functions in a literal array, they get plotted automatically in different colors, for example:
Plot [{x,x*x,-x},{x,0,10}]

But if we get the list of functions from another user-defined function, they get plotted in a single color:

fnY[x_]:={x, x*x, -x} ... OR ... fnY[x_] := List[x, x*x, -x]

Plot[fnY[x],{x,0,10}]

... even though fnY[x] evaluates to the same array as the literal array in the first example.

Why? How can we apply different colors to an array of functions constructed in a function?
 
Physics news on Phys.org
Those discussions don't quite address the particular issue I had. After some more searching it turned out that it works if you put a Evaluate[ ] around the set of functions you want to plot.