4
$\begingroup$

I want to use Listplot with Tooltipthat displays Positionof the element I'm hovering over.

data={{0,1},{1,3},{2,2}};
ListPlot[Tooltip[data]]

This is displaying the value of the element. Can I use the Positionfunction in the tooltip?

$\endgroup$
  • $\begingroup$ ListPlot[Tooltip[#, Position[data, #][[1, 1]]] & /@ data] ? $\endgroup$ – Dr. belisarius Feb 9 '15 at 16:22
1
$\begingroup$

Map and MapIndexed solutions are formally valid but Thread is often cleaner. (Poor guy is also underused, I believe.)

data = RandomInteger[10, {10, 2}];

ListPlot@Thread@Tooltip[#, Range@Length@#]&@data
$\endgroup$
  • $\begingroup$ Very Cool! Thanks to both of you! $\endgroup$ – Jason Feb 10 '15 at 15:06
7
$\begingroup$
data = Sort@RandomInteger[10, {10, 2}];
tts = {Directive[Red, 16, Bold], CellFrame -> 3, CellFrameMargins -> 5};

ListPlot[MapIndexed[Tooltip[#, First@#2, TooltipStyle -> tts] &, data],
         PlotStyle -> PointSize[Large], Frame -> True, AxesOrigin -> {0, 0}]

enter image description here

$\endgroup$

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.