Using Tooltip, is it possible to display the numeric value of the curve I've plotted using Plot and PolarPlot?

For example, is it possible to display the numeric y value of Sin[x] (or any other curve) with Tooltip?


I thought I did something like the following before, but maybe it was not for this site:

  Plot[Tooltip[Sin[x], Dynamic[y0]], {x, 0, 2 Pi}],
  "MouseMoved" :> (y0 = Sin@First@MousePosition["Graphics"]),
  • 3
    $\begingroup$ for minimal functionality this is enough Plot[Tooltip[Sin[x], Dynamic@MousePosition["Graphics"]], {x, 0, 2 Pi}] $\endgroup$ – Kuba Jul 14 '16 at 18:38
  • $\begingroup$ @Kuba D'oh! Thanks! (You can answer with that, if you like. But I'm tempted to close as dupe....) $\endgroup$ – Michael E2 Jul 14 '16 at 18:53

Potential way to achieve this:

pl = Plot[Sin[x], {x, 0, 10}];
vals = Table[Tooltip[{x, Sin[x]}, Sin[x]], {x, 0, 10, .05}];
lp = ListPlot[vals, PlotStyle -> None];
Show[{pl, lp}]

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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