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 would like to generate a ListPlot with labels that appear when the pointer goes over the individual points. Specifically, I have a table of dimensions {100,3} and I want to use the first two columns for the plot and the third for the label.

Does anyone know how to do that?

share|improve this question
    
Maybe something like: ListPlot[Tooltip@Prime[Range[25]], Filling -> Axis]. Is that what you try to do? –  Pinguin Dirk Feb 1 '13 at 14:55
    
Thanks! It is almost what I want. Say that I have a table tab of dimensions {100,3} and I want to use the first two columns for the plot and the third for the label. Do you know how to do that? –  Valerio Feb 1 '13 at 15:04
1  
Please update your question with the additional information you supplied in your comment. It makes the question quite different than as originally posted. –  m_goldberg Feb 1 '13 at 15:31
1  
Also have a look at BubbleChart. –  Jens Feb 1 '13 at 17:39

1 Answer 1

up vote 5 down vote accepted

Based on update question: It seems that ListPlot cannot handle Tooltip "directly", so I used a Table to add a Tooltip to each point.

I use the following random data:

data = Append[#, RandomChoice[{"label1", "label2", "label3"}]] & /@ 
RandomInteger[100, {10, 2}] 

(*{{80, 14, "label1"}, {98, 70, "label1"}, {66, 86, "label3"}, {43, 90, 
"label2"}, {82, 29, "label2"}, {65, 91, "label1"}, {68, 59, 
 "label3"}, {9, 56, "label1"}, {17, 50, "label2"}, {79, 99, 
 "label3"}}*)

And then plot:

ListPlot[Table[Tooltip[data[[i, 1 ;; 2]], data[[i, 3]]], {i, Length@data}]]

pointless animation added

Is this what you wanted?

EDIT

Based on Mr.Wizard's comment (see below), we can also concisely write:

ListPlot[Tooltip[{#, #2}, #3] & @@@ data]
share|improve this answer
1  
added pictures... ;) –  cormullion Feb 1 '13 at 16:35
    
@cormullion: thanks! that's something I never really understood on my mac... –  Pinguin Dirk Feb 1 '13 at 16:38
    
You can use QuickTimePlayer to record the screen, then import the file and export it to animated GIF. Of course, embedded movies would be easier... –  cormullion Feb 1 '13 at 16:46
    
ah thanks, I'll try that! (for next time) –  Pinguin Dirk Feb 1 '13 at 16:54
    
Good answer. However, you should read this, and then understand: ListPlot[Tooltip[{#, #2}, #3] & @@@ data] –  Mr.Wizard Mar 13 '13 at 16:07

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.