4
$\begingroup$

How do you make a Tooltip label expression change magnification when the Notebook magnification changes. The expr of Tooltip changes magnification but not the label.

Tooltip[
 Plot[Sin[x], {x, -2 π, 2 π}], 
 Plot[x^2, {x, 0, 2 π}, ImageSize -> Tiny]
 , 
 TooltipStyle -> {Background -> White}
]

If you examine the size of tooltip plot as you change the notebook's magnification you will see that it never changes. However, the main plot's size does change.

$\endgroup$
5
$\begingroup$

Not sure why it isn't default but you have to put in a TooltipStyle:

Magnification -> FrontEnd`AbsoluteCurrentValue[
   EvaluationNotebook[], Magnification]

FrontEnd` context is needed since it won't evaluate earlier and will be dynamically adjusted.

Tooltip[
  Plot[Sin[x], {x, -2 π, 2 π}], 
  Column[{
    Dynamic@CurrentValue@Magnification, 
    Plot[x^2, {x, 0, 2 π}, ImageSize -> Tiny]}], 
  TooltipStyle -> {
   Background -> White, 
   Magnification -> FrontEnd`AbsoluteCurrentValue[
     EvaluationNotebook[], Magnification]
}]

enter image description here


You can put use it in Stylesheet too, as an option for StyleData["TooltipLabel"].

| improve this answer | |
$\endgroup$
  • $\begingroup$ Can you let me know If I change the Magnification using Window menu, where this Magnification value stored? I checked Options[$FrontEnd, Magnification] before and after changing the Magnification but it is the same value ({Magnification -> 1.}) $\endgroup$ – Algohi Dec 7 '15 at 18:43
  • 1
    $\begingroup$ @Algohi it is local to notebook: Options[EvaluationNotebook[], Magnification]. Or CurrentValue. $\endgroup$ – Kuba Dec 7 '15 at 18:45
  • $\begingroup$ Perfect, Thanks. $\endgroup$ – Algohi Dec 7 '15 at 18:46

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.