0
$\begingroup$
Plot[Tooltip@{1.` k^2, 1.2` k^2, 1.4` k^2, 1.6` k^2, 1.8` k^2, 2.` k^2}, {k, -2, 2}]

gives

enter image description here

But why does

Plot[Tooltip@Evaluate@Table[a k^2, {a, 1, 2, 0.2}], {k, -2, 2}]

give

enter image description here with no color difference?

$\endgroup$
5
  • 1
    $\begingroup$ Evaluate has to be right after Plot. Try Plot[Evaluate@Tooltip@Table[a k^2, {a, 1, 2, 0.2}], {k, -2, 2}]. $\endgroup$
    – Michael E2
    Commented Apr 1, 2013 at 2:21
  • 1
    $\begingroup$ Related: this question, the second half of this answer, and perhaps this discussion. $\endgroup$
    – Michael E2
    Commented Apr 1, 2013 at 2:33
  • $\begingroup$ @MichaelE2 Thank you. But I still don't get it. In the first example, I use Tooltip@List in Plot, it works well. In the second example, I use "Evaluate" before "Table" in order to turn the "Table" expr into a list first, because I know "Plot" will consider the "Table" as a single entity without "Evaluate", So I think it should be the same as the first example with "Evaluate". But it is not. And you proposed to let the "Evaluate" before "Tooltip", then it works! Wow, I still don't know why. $\endgroup$
    – matheorem
    Commented Apr 1, 2013 at 2:49
  • 1
    $\begingroup$ @matheorem When you pinned down the error, you always have to check the doc's of Evaluate again. Under Details it clearly says: "Evaluate only overrides HoldFirst, etc. attributes when it appears directly as the head of the function argument that would otherwise be held". Therefore, Evaluate has always be the most outwards function of an argument: f[Evaluate[...],...]. $\endgroup$
    – halirutan
    Commented Apr 1, 2013 at 4:13
  • $\begingroup$ @matheorem It takes a while to get used to the fact that some Mathematica commands hold (keep unevaluated) some or all of the arguments, and Evaluate overrides it. Evaluate@Tooltip@Table... evaluates to Tooltip@List... before being passed to Plot. I don't know what else to add to halirutan's explanation. $\endgroup$
    – Michael E2
    Commented Apr 1, 2013 at 10:21

0

Browse other questions tagged or ask your own question.