Skip to main content
added 745 characters in body
Source Link
march
  • 24.2k
  • 2
  • 46
  • 102

Here's a quick fix:

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

If you investigate under the hood,

Cases[
  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.

Here's a quick fix:

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

Here's a quick fix:

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

If you investigate under the hood,

Cases[
  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.

Source Link
march
  • 24.2k
  • 2
  • 46
  • 102

Here's a quick fix:

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