Tooltip works fine in ListPlot:

ListPlot[Table[Tooltip[PDF[PoissonDistribution[10], x]], {x, 0, 20}]]

in which the decimal value of the distribution at a point is revealed when a cursor is placed over that data point.

How does one get the same functionality using DiscretePlot? For instance,

DiscretePlot[Tooltip[PDF[PoissonDistribution[10], x]], {x, 0, 20}]

reveals "PDF[PoissonDistribution[10], x]" (rather than the desired numerical value) when a cursor is placed over a data point.

I've tried a number of obvious alternatives, such as Tooltip with two arguments and Evaluate or N (numerical value) applied to the PDF. None work.


2 Answers 2


Here's a quick fix:

  Tooltip[PDF[PoissonDistribution[10], x]]
  , {x, 0, 20}] /. Tooltip[a_, b_] :> Map[Tooltip[Point[#], Last@#] &, a[[3, 1]]]

If you investigate under the hood,

  ListPlot[Table[Tooltip[PDF[PoissonDistribution[10], x]], {x, 0, 1}]]
  , Tooltip[a__] :> {a}
  , Infinity]
(* { {{Opacity[0.], Point[{{1., 0.0000453999}}]}, 0.0000453999}
     , {{Opacity[0.], Point[{{2., 0.000453999}}]}, 0.000453999} } *)

so that each point gets its own Tooltip labeled with the value, whereas

Cases[DiscretePlot[Tooltip[PDF[PoissonDistribution[10], x]], {x, 0, 1}]
  , Tooltip[a__] :> a
  , Infinity]
(* {{{}, Null, Point[{{0., 0.0000453999}, {1., 0.000453999}}], {}}
     , PDF[PoissonDistribution[10],x]} *)

In DiscretePlot, the second argument of Tooltip is PDF[PoissonDistribution[10],x], which means each point will be labeled with that expression. I do not know why it does this.

  • $\begingroup$ Thanks. Your quick fix suffices. Solution accepted. (I wish there were a more elegant solution, however.) $\endgroup$ Sep 4, 2015 at 23:17
  • $\begingroup$ @DavidG.Stork. There might be! ciao very briefly had a comment with something that almost seemed to work, so perhaps something along those lines might work. As far as Tooltip and DiscretePlot working together nicely, who knows if there's correct syntax for that. I tend for quick fixes and kluges if it's not too inelegant. $\endgroup$
    – march
    Sep 4, 2015 at 23:19
  • 2
    $\begingroup$ @march: Yes, that was thiiiisss close, eh? Afraid it was a dead end, your method seems sound (upvoted it and question). Perhaps one of the deep evaluation spelunkers here can enlighten why one can't get at the evaluated value for use in tooltip, or a way to do it... $\endgroup$
    – ciao
    Sep 5, 2015 at 0:45


Your ListPlot example is shifted from the proper location since the data is assumed to start with 1 rather than 0. To correct this, you can either enter data points or specify the DataRange. You can use the option Filling->Axis to get the same format as you would with DiscretePlot.

 Tooltip[PDF[PoissonDistribution[10], #]] & /@ Range[0, 20], 
 DataRange -> {0, 20}, Filling -> Axis]

enter image description here

  • $\begingroup$ Yes. You are correct about the unit offset. $\endgroup$ Sep 4, 2015 at 23:19
  • $\begingroup$ Excellent! Going meta. $\endgroup$
    – march
    Sep 4, 2015 at 23:21

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.