Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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.

share|improve this question

2 Answers 2

up vote 3 down vote accepted

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.

share|improve this answer
    
Thank you, I do like the way this looks. Especially when you are presenting larger fonts on a projector screen! –  Joseph Jan 6 '13 at 14:42

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}]
share|improve this answer
    
This is exactly I was looking for, Thank you very much! –  Joseph Dec 21 '12 at 20:10

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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