13

3

I have a function that takes a numeric argument and returns a list of numbers. I want to plot each element of the list in a different color.

If I use this command,

```
Plot[f[x],{x,-1,1}]
```

all the elements are plotted in the same color. The function takes only a numeric argument (its definition is `f[x_?NumericQ]:=...`

) so I can't use `Evaluate`

like in this question.

So far I've been using this command:

```
Plot[{f[x][[1]],f[x][[2]],f[x][[3]],f[x][[4]]},{x,-1,1}]
```

Which works fine (since the function evaluates very fast, I don't mind there are redundant evaluations here, see this question). However this is not very elegant, and considering I have 16 elements to plot, it gets downright ugly.

**Is there a more elegant way to plot each element in a different color?**

The two highest voted answers below are

– Mr.Wizard – 2015-05-25T13:59:51.200effectively duplicatesof answers to (8637). For this reason I argue that this question is a duplicate of that one. Please vote to close if you agree or comment here if you do not.1How about

`Plot[Evaluate[f[x]], ...]`

? – wxffles – 2012-11-14T19:08:16.7101@wxffles if you have

`f[x_?NumericQ]:=...`

(as indicated in the question) then that doesn't work. – acl – 2012-11-14T19:19:30.9631Identical question asked prior to mathematica.SE existence. – Sasha – 2012-11-14T19:29:46.553

@Sasha - in the question you linked to the problem is to avoid redundant evaluations of the function, since it is expensive to evaluate (just like in this question, which is already mentioned above). In my question I don't mind redundant evaluations, my problem is coding style. These are two different issues.

– Joe – 2012-11-15T08:27:12.367