1
$\begingroup$

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

Plot[{f1,f2,...},{x,xmin,xmax}]

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?

$\endgroup$

closed as off-topic by Quantum_Oli, Bob Hanlon, Edmund, bbgodfrey, m_goldberg Aug 23 '16 at 1:08

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "This question arises due to a simple mistake such as a trivial syntax error, incorrect capitalization, spelling mistake, or other typographical error and is unlikely to help any future visitors, or else it is easily found in the documentation." – Bob Hanlon, Edmund, bbgodfrey
If this question can be reworded to fit the rules in the help center, please edit the question.

1
$\begingroup$

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

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

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