Why is Tooltip not working in Manipulate?

Dear All,

Please can you help !

Probably a simple question, but why is tooltip not working in the Manipulate code? See also attached file ‘with’ and without ‘Tooltip’.

Manipulate[Tooltip[
  L = Length@datafreqt];
 mm = MovingAverage[datafreqt[[ Range[a, b] ]], m];
 If[L - 1 > a >= b, b = a + 1];
 If[a === L, a = L - 1; b = L];
 If[m > b - a, m = b - a];
 
 Pane[
  Graphics[
   {Thin, GrayLevel[.5], Line@Transpose[{Range@L, datafreqt}]
    , Thick
    , Red
    , Line@Transpose[
      {Range[a, b, (b - a)/(Length[mm] - 1)],
       mm}]}
   , PlotLabel -> Style["Test with TOOLTIP", "Title", 12]
   , BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", 
     FontSize -> 11}
   , Frame -> True
   , FrameLabel -> {"Test [%]", "Test [n]"}
   , GridLines -> Automatic
   , GridLinesStyle -> Directive[Black, Dotted]
   , PlotRange -> {{0, 101}, {0, 200}}
   , AspectRatio -> .5
   , Axes -> True
   , Ticks -> {None, Automatic}]
  , ImageSize -> 350]
 , {{m, 1, "m\[Hyphen]day moving average"}, 1, Max[b - a, 1], 1, 
  Appearance -> "Labeled"}
 , "time span:"
 , {{a, Floor[.25 L], "lower limit"}, 1, L, 1, Appearance -> "Labeled"}
 , {{b, Floor[.75 L], "upper limit"}, 1, L, 1, Appearance -> "Labeled"}
 , SaveDefinitions -> True
 , TrackedSymbols -> True
 
 ]

I’m not exactly sure where you want the tool tip… but if you want it on the graphics you have to wrap it around the graphics function. Does this help? See below…

Manipulate[L = Length@datafreqt;
 mm = MovingAverage[datafreqt[[ Range[a, b] ]], m];
 If[L - 1 > a >= b, b = a + 1];
 If[a === L, a = L - 1; b = L];
 If[m > b - a, m = b - a];
 
 Pane[
  Tooltip[Graphics[
    {Thin, GrayLevel[.5], Line@Transpose[{Range@L, datafreqt}]
     , Thick
     , Red
     , Line@Transpose[
       {Range[a, b, (b - a)/(Length[mm] - 1)],
        mm}]}
    , PlotLabel -> Style["Test with TOOLTIP", "Title", 12]
    , BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", 
      FontSize -> 11}
    , Frame -> True
    , FrameLabel -> {"Test [%]", "Test [n]"}
    , GridLines -> Automatic
    , GridLinesStyle -> Directive[Black, Dotted]
    , PlotRange -> {{0, 101}, {0, 200}}
    , AspectRatio -> .5
    , Axes -> True
    , Ticks -> {None, Automatic}], "place tip here"]
  , ImageSize -> 350]
 , {{m, 1, "m\[Hyphen]day moving average"}, 1, Max[b - a, 1], 1, 
  Appearance -> "Labeled"}
 , "time span:"
 , {{a, Floor[.25 L], "lower limit"}, 1, L, 1, Appearance -> "Labeled"}
 , {{b, Floor[.75 L], "upper limit"}, 1, L, 1, Appearance -> "Labeled"}
 , SaveDefinitions -> True
 , TrackedSymbols -> True
 
 ]

Hi Michael,

Thanks for your reply and help.

Here some more details. The tooltip should show the peak data, simular as in the Scatterplot bellow. Do you know if this is possible in Manipulate?

scatterplot = 
 ListPlot[Tooltip[datafreq], AxesLabel -> {"Test", "Test"},
  PlotStyle -> Directive[PointSize[Small], Blue],
  Filling -> Axis] 

Many thanks for your help !

File attached: Test with Tooltip_2.nb

Are you looking for something like this? I couldn’t figure out how to make the tool tip work correctly with the graphics primitive so I just used a ListPlot instead. You should be able to play around with this and get what you want. There’s probably a way to do it with the Point graphics primitive, but couldn’t figure out off hand.

Also… I get a lot of my tough questions answered on stackoverflow.com, formally stackexchange.com. They have a mathematica forum that’s awesome. I started using it a couple months ago and I’m stoked. I find that my questions get answered quick, and there’s people moderating to make sure everything is organized. Hope this helps. I like the wolfram community too… but in my experience its not quite as helpful. I still jump on here sometimes though. Good luck!

Manipulate[L = Length@datafreqt;
 mm = MovingAverage[datafreqt[[Range[a, b]]], m];
 If[L - 1 > a >= b, b = a + 1];
 If[a === L, a = L - 1; b = L];
 If[m > b - a, m = b - a];
 
 
 Pane[Show[
   
   ListPlot[Tooltip[Transpose[{Range@L, datafreqt}]], 
    PlotStyle -> PointSize[.01]],
   
   Graphics[{
     
     Thin, GrayLevel[.5], Line@Transpose[{Range@L, datafreqt}],
     
     Thick, Red, 
     Line@Transpose[{Range[a, b, (b - a)/(Length[mm] - 1)], mm}]},
    
    
    
    
    PlotLabel -> Style["Test with TOOLTIP", "Title", 12], 
    BaseStyle -> {FontFamily -> "Arial", FontWeight -> "Bold", 
      FontSize -> 11}, Frame -> True, 
    FrameLabel -> {"Test [%]", "Test [n]"}, GridLines -> Automatic, 
    GridLinesStyle -> Directive[Black, Dotted], 
    PlotRange -> {{0, 101}, {0, 200}}, AspectRatio -> .5, 
    Axes -> True, Ticks -> {None, Automatic}], PlotRange -> {0, 200}],
   ImageSize -> 350], {{m, 1, "m\[Hyphen]day moving average"}, 1, 
  Max[b - a, 1], 1, 
  Appearance -> "Labeled"}, "time span:", {{a, Floor[.25 L], 
   "lower limit"}, 1, L, 1, 
  Appearance -> "Labeled"}, {{b, Floor[.75 L], "upper limit"}, 1, L, 
  1, Appearance -> "Labeled"}, SaveDefinitions -> True, 
 TrackedSymbols -> True]

Hi Michael,

Many thanks for your help. The code with ‘ListPlot - Tooltip’ seems fine for me.

Again, thanks for your time and excellent support !

Cheers,…Jos

Great! No problem.