2
$\begingroup$

If k=3, then I would like the following to say "Sine Curve, k=3" when you hover over the output of the Tooltip command:

Tooltip[Sin[k*x], "Sine Curve, k=", TooltipStyle -> FontSize -> 16]

I have made a number of attempts, using pure functions and substitutions, but none delivered the output I want. The ultimate goal is to put this into a Manipulate where k is a user selectable value and the Sin[k x] function is plotted.

$\endgroup$
3
$\begingroup$

String manipulation like in jVincent's answer is nice, but I normally prefer to combine these types of elements using Row:

Manipulate[
 Plot[Tooltip[Sin[k x], Row[{"Sine Curve, k=", k}]], {x, 0, 4 Pi}], 
      {k, 1, 5}]

For more complicated objects, it just normally ends up being neater. Maybe my preference comes from having to work with RowBox and MakeExpression too much...
Aside: I would also use "\[VeryThinSpace]\[LongEqual]\[VeryThinSpace]" instead of just "=",
it looks nicer:
example
and in Mathematica, "=" is normally associated with Set.

$\endgroup$
  • $\begingroup$ Thank you, I do like the way this looks. Especially when you are presenting larger fonts on a projector screen! $\endgroup$ – Joseph Jan 6 '13 at 14:42
4
$\begingroup$

You can insert the value into the tooltip using ToString:

Manipulate[
 Plot[Tooltip[Sin[k x], "Sine Curve, k=" <> ToString[k]], {x, 0, 4 \[Pi]}],
 {k, 1, 5}]
$\endgroup$
  • 1
    $\begingroup$ This is exactly I was looking for, Thank you very much! $\endgroup$ – Joseph Dec 21 '12 at 20:10

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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