I am trying to plot three fits simultaneously:

Plot[Table[#[x, t], {t, {1, 3, 5}}], {x, -10, 10}] & /@ ϕContfit

Where ϕContfit is a list of fits, each of two variables x ant t, from NonlinearModelFit. I am making a list of plots, where each plot will show the fit at t = 1, 3, and 5 for x in the range of -10 to 10.

The documentation of the Plot function indicates that the following code


should plot each function and automatically color each function with a different color; however, when I run the first line shown above each plot colors the functions the same. Here is one element of the list of plots:

Three plots have the same color

If I try to indicate the style of each function, it just gives all three the last color (in this case, green):

Plot[Table[#[x, t], {t, {1, 3, 5}}], {x, -10, 10}, 
   PlotStyle -> {Red, Blue, Green}] & /@ ϕContfit

However, if instead of using the Table function I explicitly write out the functions:

Plot[{#[x, 1], #[x, 3], #[x, 5]}, {x, -10, 10}] & /@ ϕContfit

then the Plot function colors everything fine (each functions is automatically colored differently).

I want to generalize this to different plots, different values, etc., so it would be helpful if I could use the Table (or some other) function to color everything correctly. How do I accomplish this?


I figured it out. Just need to add an Evaluate function:

Plot[Evaluate@Table[#[x, t], {t, {1, 3, 5}}], {x, -10, 
10}] & /@ ϕContfit

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