Message Boards Message Boards

0
|
7486 Views
|
5 Replies
|
1 Total Likes
View groups...
Share
Share this post:

Why is Tooltip not working in Manipulate?

Posted 9 years ago

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

 ]
Attachments:
POSTED BY: Jos Klaps
5 Replies

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

POSTED BY: Jos Klaps

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

 ]
POSTED BY: Michael McCain

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

Attachments:
POSTED BY: Jos Klaps

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]
POSTED BY: Michael McCain

Great! No problem.

POSTED BY: Michael McCain
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract