3

I understand that this has been asked before, but none of the solutions are working for me:

I'm plotting a function for many different values of a variable, z, using Map. I have the Evaluate->True tag, and my plots are appearing as different colors, but try as I might I can't seem to get the labels for more than the first line.

Here is what I have:

zlist = Table[z, {z, zmin, zmax, zincrement}]

Plot[Map[function[x, #] & , zlist], {x, 1, 10}, 
 Evaluated -> True, PlotLegends -> zlist]

It generates the expected plot with each line in a different color, but with only one label! This shouldn't be happening as far as I have been able to determine. Not sure what's going on.

edit - i've been linked to a solution: If you manually wrap the Map function in Evaluate[], rather than using Evaluate->True, it works. Feels like a bug, but just in case anyone runs into it that's a simple workaround.

Nate
  • 103
  • 5

1 Answers1

2

I'm not sure why it's happening, but replacing the Evaluated->True with Evaluate in front of your Map fixes the situation:

zlist = {1, 2, 3};
Plot[Evaluate@Map[Sin[x #] &, zlist], {x, 1, 10}, PlotLegends -> zlist]

enter image description here

BlacKow
  • 6,428
  • 18
  • 32