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.

Version 9, windows 7:

When I use ListLinePlot Tooltip does not work any more. It seems to have been lost somewhere. With same data, Tooltip works ok using ListPlot.

data = Table[Tooltip[{x, x^2}], {x, 0, 10, .1}];
ListPlot[data]
(* Tooltip shows ok *)

ListLinePlot[data]
(* Tooltip does not show up *)

enter image description here

Looked at possible issues for ListLinePlot and do not seen mention of this.

question: How to make Tooltip work with ListLinePlot

thanks

share|improve this question
    
I get tool-tips from ListLinePlot in version 7. Should this be tagged version-9? –  Mr.Wizard Dec 18 '12 at 8:53
add comment

2 Answers

up vote 8 down vote accepted

Well it will get lost even in the case of ListPlot if you go to continuous solid line case:

ListPlot[data, Joined -> True]

In both cases the fix is to bring back points somehow, for example using Mesh:

ListLinePlot[data, Mesh -> All, MeshStyle -> Opacity[0]]

OR any similar trick in that manner:

Show[ListLinePlot[data], ListPlot[data, PlotStyle -> Opacity[0]]]

The reason for this is probably the fact that in bare solid-line case you get only line segments in resulting Graphics primitives (check with InputForm[..."your plot"...]). And line segments are wrong to wrap Point tool-tips around.

@MikeHoneychurch recommendation will work too; if you want to see only the solid line (with no point marks) something like empty string this will do

ListLinePlot[data, PlotMarkers -> ""]

To answer Mike's comment on Tooltip on line segments - it does work if constructed properly, for example (otherwise mma wouldn't know what to show when mouseover happens, I think):

data = Table[{x, x^2}, {x, 0, 10, .1}];
Graphics[Tooltip[Line[#]] & /@ Partition[data, 2, 1]]
share|improve this answer
    
Alternatively you could add plot markers to enable the tooltips. –  Mike Honeychurch Dec 18 '12 at 3:30
    
@MikeHoneychurch thanks Mike, updated. +1 to you btw. –  Vitaliy Kaurov Dec 18 '12 at 3:38
    
@MikeHoneychurch I added some thoughts in the answer. –  Vitaliy Kaurov Dec 18 '12 at 3:47
add comment

As Vitaly has indicated, you need to have a point to tooltip over. Another approach is to add plot markers -- not suitable if a large number of points present:

data = Table[Tooltip[{x, x^2}], {x, 0, 10, .1}];
ListLinePlot[data, PlotMarkers -> Automatic]

Edit

As per my conversation with Vitaly you can tooltip your line. I had forgotten about that.

data = Table[{x, x^2}, {x, 0, 10, .1}];
ListLinePlot[Tooltip[data, "this line is my data"]]
share|improve this answer
    
I think ti works like this: Graphics[{Tooltip[Line[RandomReal[1, {15, 2}]], "hello"]}] –  Vitaliy Kaurov Dec 18 '12 at 4:06
    
Yes you're right. I thought I'd tried that once and it didn;t work. oh well! –  Mike Honeychurch Dec 18 '12 at 4:15
add comment

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.