3
$\begingroup$

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.

$\endgroup$
3
  • 2
    $\begingroup$ I'm gonna report this as a bug, works fine in version 9 $\endgroup$
    – Jason B.
    Jul 29, 2016 at 18:24
  • $\begingroup$ @Jason, as a reminder: Evaluated is undocumented; caveat emptor and all that jazz. ;) $\endgroup$ Jul 29, 2016 at 18:35
  • $\begingroup$ Well, I know what reply I'll get on the bug report now then :-D $\endgroup$
    – Jason B.
    Jul 29, 2016 at 18:39

1 Answer 1

2
$\begingroup$

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

$\endgroup$

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