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.

I came upon a strange Tooltip behavior in ListPlot and ListLogPlot. Consider the following code:

data={{{1, 0.755384}, {21, 0.73102}, {41, 0.425711}, {61, 0.344925}, {81,0.298442}, {101, 0.152632}, {121, 0.0959704}, {141, 0.0648073}, {161, 0.04575}, {181, 0.0355283}, {201, 0.0350886}, {221, 0.0697085}, {241, 0.125175}, {261, 0.144639}, {281, 0.0730912}, {301, 0.0833903}}, {{1, 0.244886}, {21, 0.268764}, {41, 0.574521}, {61, 0.655075}, {81, 0.701431}, {101, 0.847269}, {121, 0.903783}, {141, 0.935137}, {161, 0.95431}, {181, 0.964333}, {201, 0.964812}, {221, 0.930292}, {241, 0.874787}, {261, 0.855361}, {281, 0.926909}, {301, 0.916631}}};

ListPlot[
 MapIndexed[Tooltip[#1, {"A", "B"}[[First[#2]]]] &, data], 
 Joined -> True, PlotRange -> All]

enter image description here

and

ListLogPlot[
 MapIndexed[Tooltip[#1, {"A", "B"}[[First[#2]]]] &, data], 
 Joined -> True, PlotRange -> All]

enter image description here

Surprisingly, the Tooltip is lost in the first plot but appears in the LogListPlot. Does anybody know why and how to rediscover the Tooltip in the ListPlot?

EDIT 1:

To elaborate a Little on the weirdness of the Problem. The Tooltips work in ListPlot for different data sets.

For example the following Shows perfect Tooltips:

data2={{{1, 0.999287}, {21, 0.760537}, {41, Missing[]}, {61, Missing[]}, {81, Missing[]}, {101, Missing[]}, {121, Missing[]}, {141, Missing[]}, {161, Missing[]}, {181, Missing[]}, {201, Missing[]}, {221, Missing[]}, {241, Missing[]}, {261, Missing[]}, {281, Missing[]}, {301, Missing[]}}, {{1, 0.000595082}, {21, 0.172139}, {41, 0.32012}, {61,0.229145}, {81, 0.180066}, {101, 0.0638401}, {121, Missing[]}, {141, Missing[]}, {161, Missing[]}, {181, Missing[]}, {201, Missing[]}, {221, Missing[]}, {241, Missing[]}, {261, Missing[]}, {281, 0.0069369}, {301, Missing[]}}, {{1, Missing[]}, {21, Missing[]}, {41, 0.550466}, {61,0.683027}, {81, 0.744493}, {101, 0.863833}, {121, 0.878976}, {141,0.875153}, {161, 0.865458}, {181, 0.858256}, {201, 0.862768}, {221, 0.904684}, {241, 0.949275}, {261, 0.969743}, {281,0.978723}, {301, 0.820449}}, {{1, Missing[]}, {21, Missing[]}, {41, Missing[]}, {61, Missing[]}, {81, Missing[]}, {101, Missing[]}, {121, 0.0768691}, {141, 0.0943452}, {161, 0.111187}, {181, 0.123562}, {201, 0.12506}, {221,0.0852941}, {241, 0.0385046}, {261, 0.0163843}, {281, Missing[]}, {301, Missing[]}}, {{1, Missing[]}, {21, Missing[]}, {41, Missing[]}, {61, Missing[]}, {81, Missing[]}, {101, Missing[]}, {121, Missing[]}, {141, Missing[]}, {161, Missing[]}, {181, Missing[]}, {201, Missing[]}, {221, Missing[]}, {241, Missing[]}, {261, Missing[]}, {281, Missing[]}, {301, Missing[]}}, {{1, Missing[]}, {21, Missing[]}, {41, Missing[]}, {61, Missing[]}, {81,Missing[]}, {101, Missing[]}, {121, Missing[]}, {141, Missing[]}, {161, Missing[]}, {181, Missing[]}, {201, Missing[]}, {221, Missing[]}, {241, Missing[]}, {261, Missing[]}, {281, Missing[]}, {301, 0.128235}}};

ListPlot[
 MapIndexed[Tooltip[#1, {"A", "B", "C", "D", "E", "F"}[[First[#2]]]] &, data], 
 Joined -> True, PlotRange -> All]

enter image description here

share|improve this question
    
try ListLinePlot (you can then drop Joined->True as well). Works for me, please confirm (9.0.1). Weird nevertheless! –  Pinguin Dirk Sep 27 '13 at 14:25
    
Yes ListLinePlot works (9.0.1). The strange thing is that I have many instances of ListPlots where the Tooltip does NOT vanish. –  Markus Roellig Sep 27 '13 at 14:50
    
@MarkusRoellig Do all those have Joined -> True as well? –  rm -rf Sep 27 '13 at 14:55
    
@rm-rf Yes, it is always the same plot function just with different data. Weird stuff. –  Markus Roellig Sep 27 '13 at 15:04
    
Hmm... that's weird. I thought it might be related to the fact that ListPlot plots points and then somehow the tooltips got stripped when converting to a line, but that doesn't seem to be the case. It does seem to work with PlotMarkers, so perhaps you could set the plot markers to be a veeery small size? –  rm -rf Sep 27 '13 at 15:06

2 Answers 2

I tracked this down a few years ago. Around version 6 or 7 I was writing a function to put a legend on a plot based on the Tooltip wrapped around each data set. It worked on all plots except ListPlot. Back then some of the graphing functions were in an external package instead of built-in, so I could open the package and look at the code.

Apparently, for version 6 the plotting functions had to be rewritten to use the OpenGL instead of the old Postscript(ish) graphics. They also introduced Annotations (such as Tooltip) in that version. All the plotting functions got upgraded to OpenGL, but for some reason ListPlot was left out when adding Annotations. Instead, a new function ListLinePlot was added. ListLinePlot is not simply ListPlot with Joined->True, but is newer code than ListPlot.

I simply try to remember to use ListLinePlot, but most of the time it doesn't matter.

share|improve this answer

Add to your ListPlot the following option:

PerformanceGoal -> "Give me the tooltips!"

and you'll have them. Another way is to use the option:

Method -> {"If tooltips are lost", "Find them and plot them"}

If you're not comfortable with these commands, use more mathematical

InterpolationOrder -> 1

share|improve this answer

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.