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.

Is it possible to change the position of tool tips, which currently always appear to the lower right of the mouse position. In the screen grab below the mouse is over 10000000 and the tooltip appears to the bottom right (8.0.4 on Mac).

enter image description here

By way of an example how would you go about making the tooltip appear to the bottom left (courtesy of photo editing):

enter image description here

(This was originally asked on StackOverflow, but it did not draw any answers.)

share|improve this question
    
We'll see if this draws answers here. –  rcollyer Feb 2 '12 at 3:31
    
On my system (Mathematica 8.0.1 Linux x64) the tooltip is displayed at the mouse position, not necessarily at the bottom right. –  David Z Feb 2 '12 at 6:46
    
thanks @David. Just added an edit: my system is Mac. I wonder if that means that the position is something that Mma takes from the operating system. –  Mike Honeychurch Feb 2 '12 at 6:51
2  
It's easy to get the tooltip to come up to the left of the cursor; position your content along the right edge of your screen... ;-) –  Brett Champion Mar 6 '12 at 1:26
5  
Sorry, if it's a real tooltip, the answer is just simply no. Can't be done. The positioning algorithm is hard-coded into the FE source code (I just checked) and is not user-settable. You might be able to find some way to create a fake tooltip-like thing which you can have more control over, but it's just not going to be possible with the real thing. FWIW, you're the first person I'm aware of to ask for this functionality. Wasn't even on my radar before. –  John Fultz Mar 6 '12 at 4:12
show 5 more comments

1 Answer 1

up vote 10 down vote accepted
+50

Improvised Tooltip using Text and Mouseover

Here's one way to improvise a tooltip for graphics objects--in this case, a list of points. It emulates a tooltip but does not leave a a drop shadow, and as István notes, has a few graphical shortcomings that make it less than ideal (clipping, under axes layer). Also, the code would need to be tweaked for objects displayed through functions other than Graphics.

[Edit: The present version makes use of Heike's suggestion to use the third parameter of Text for the offset. As Heike notes, "The units of the third argument of Text are scaled with respect to the bounding box of the first argument where {0,0} corresponds to the centre, {-1,-1} to the lower left corner, {1,1} to the upper right corner etc."]

Graphics[{PointSize[Medium], 
    Table[Mouseover[Point[p], {Point[p], 
        Text[Framed[p, Background -> LightYellow], p, {1.25, 2}]}], 
    {p, RandomReal[1, {10, 2}]}]}, Frame -> True, 
    PlotRange -> {{0, 1}, {0, 1}}, ImagePadding -> {{100, 10}, {50, 5}}]

tooltip

share|improve this answer
    
You could use the third argument of Text for the vertical displacement as well, for example Text[Framed[p, Background -> LightYellow], p, {1.2, 1}]. This would make the relative position of the label independent of the plot range of the plot. –  Heike Mar 8 '12 at 10:07
    
Thanks. I figured out how to use Scaled. What units does your adjustment use? They are not the same as scaled. Nor are they printer's points. –  David Carraher Mar 8 '12 at 10:24
    
It looks like the third argument of Text uses characters (in the current font size) as units. If so, that is a nice alternative to Scaled. –  David Carraher Mar 8 '12 at 10:32
    
The units of the third argument of Text are scaled with respect to the bounding box of the first argument where {0,0} corresponds to the centre, {-1,-1} to the lower left corner, {1,1} to the upper right corner etc. –  Heike Mar 8 '12 at 10:51
    
This would seem to imply that the displacement of the tooltip will vary according to the size of the text bounding box, correct? –  David Carraher Mar 8 '12 at 11:00
show 2 more comments

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.