How is it possible to map a list of Tooltip values to the functions being plotted?

For example: Assume, f1[x], f2[x], f3[x]... are functions defined. {t1, t2, t3, ...} are the list of tool-tips to display.

Then to plot: Plot[ Tooltip[{f1[x], f2[x], ... }], {x, a, b}]; Which will just display the functions as tool-tip OR Plot[ {Tooltip[f1[x], t1], Tooltip[f2[x], t2], ...... }, {x, a, b}]

Which is the required behavior, but, is there another shorter or direct way of mapping the functions f1, f2, f3, ... to t1, t2, t3, .... rather than manually?


1 Answer 1

funcs = {Sin[x], Cos[x], Sin[x] Cos[x]};
tips = {"t1", "t2", "t3"};

Plot[Thread[Tooltip[funcs, tips]], {x, -2 Pi, 2 Pi}, Evaluated -> True]
Plot[Evaluate@Thread[Tooltip[funcs, tips]], {x, -2 Pi, 2 Pi}]
Plot[Evaluate@MapThread[Tooltip, {funcs, tips}], {x, -2 Pi, 2 Pi}]
Plot[Tooltip @@@ Transpose[{funcs, tips}], {x, -2 Pi, 2 Pi}, Evaluated -> True]

all give

enter image description here

  • $\begingroup$ I've never seen the Evaluated option before. Is it undocumented? $\endgroup$ Mar 19, 2015 at 17:48
  • $\begingroup$ @2012rcampion, it is undocumented as of version; don't know if version 10 has it documented. See other appearances of Evaluated on this site $\endgroup$
    – kglr
    Mar 19, 2015 at 17:53
  • $\begingroup$ Nice, it works. $\endgroup$ Mar 19, 2015 at 17:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

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