Search code examples
tooltipwolfram-mathematica

How can I make a Tooltip to show only the epilog value on a ListLinePlot when hover?


So, I have many images of Zeeman interference patterns. My task is to find the positions of the intensity peaks. I've already written a script that finds the maximum values, so I could choose the values which I need by "hand", but that would be very-very boring, and it would take a long time.

kep = Import["C:\Users\Martin\Documents\Egyetem\4. félév\Modern fizika \labor\6. Zeeman-effektus\sigma_50.png"];
adat = ImageData[kep, "Byte"][[577]][[All, 1]];
csucsok = N[FindPeaks[adat, 0.6, 0.6, 75]];
ListLinePlot[adat, AxesLabel -> {"Pixel", "Intenzitás"}, PlotLabel -> "sigma_50.png", ImageSize -> Large, PlotTheme -> "Classic", Epilog -> {Red, PointSize[0.008], Point[csucsok]}]

I would be good to have little tooltips which shows the position(x axis value) of a red dot(and only the red dots), and the intensity value(y axis) when I click on them, or the mouse is over them. Are there any way to do this?


Solution

  • maybe make your Tooltip points a separate plot:

     data = Table[{i, RandomReal[{-1, 1}]}, {i, 20}];
     toplot = Select[data, #[[2]] > 0 & ];
     Show[{
          ListLinePlot[ data],
          ListPlot[Tooltip[toplot], PlotStyle -> {PointSize[.05], Red}]}]
    

    (We cant really see what you are doing without your data..)