MathGroup Archive 2008

[Date Index] [Thread Index] [Author Index]

Search the Archive

Tooltips with 2 data points

  • To: mathgroup at smc.vnet.net
  • Subject: [mg84603] Tooltips with 2 data points
  • From: "Thomas Muench" <thomas.muench at gmail.com>
  • Date: Sun, 6 Jan 2008 05:59:17 -0500 (EST)

Hello Mathgroup,

I have a question about getting Tooltips to work in a ListPlot when I
only have 2 data points. I have a Dynamic[...] application in which
the user adds measurements sequentially (start with one data point,
then 2, then 3, etc.). A ListPlot is being displayed after each
measurement. There are 3 quantities that are being measured. So, after
1 measurements, I have 3 numbers, after 2 measurements I have 3 number
pairs, then I have 3 number triplets, etc. I want to display the data
points with ListPlot[...], and also use Tooltip on the data points,
but I cannot get a working ListPlot with Tooltips after the second
measurement (the Tooltips work for all other n, but not for n=2).

Here is a simple example that shows the dilemma. Does anybody know a
way around this? Or is it a bug of Tooltip[...]?

Thank you for any suggestions,
thomas

Style["This is some example data (3 quantities, 4 measurements \
each):", Bold, Red, 16]
data = {{41, 39, 44, 43}, {65, 61, 68, 67}, {59, 55, 62, 61}}
Style["Measurements are taken sequentially for each quantity\nand \
plotted after each measurement", Bold, Red, 16]
Style["mimmicked here with seqData[n_]:=Take[#,n]&/@data", "Input"]
seqData[n_] := Take[#, n] & /@ data;
Style["Plotting the raw data brakes down at n=2:", Bold, Red, 16]
Style["ListPlot[seqData[n], \[Ellipsis] ]", "Input"]
Grid[Table[{Style[Row[{"n=", n}], Bold, 16],
   ListPlot[seqData[n], Frame -> True, Axes -> False,
    PlotStyle -> PointSize[Large], ImageSize -> 200,
    PlotRange -> If[n != 2, {{0, 5}, {0, 100}}, All]],
   seqData[n]}, {n, 4}]]
Style["This can be rescued by explicitly plotting (x,y) number \
pairs:", Bold, Red, 16]
Style["ListPlot[Transpose[{Range[n],#}]&/@seqData[n], \[Ellipsis] ]", \
"Input"]
Grid[Table[{Style[Row[{"n=", n}], Bold, 16],
   ListPlot[Transpose[{Range[n], #}] & /@ seqData[n], Frame -> True,
    Axes -> False, PlotStyle -> PointSize[Large], ImageSize -> 200,
    PlotRange -> {{0, 5}, {0, 100}}],
   Transpose[{Range[n], #}] & /@ seqData[n]}, {n, 4}]]
Style["Now I add Tooltips, it again brakes down for n=2:", Bold, Red, \
16]
Style["ListPlot[Map[Tooltip[#,ToString[#\[LeftDoubleBracket]2\
\[RightDoubleBracket]]<>\"%\"]&,Transpose[{Range[n],#}]&/@seqData[n],{\
2}], \[Ellipsis] ]", "Input"]
Grid[Table[{Style[Row[{"n=", n}], Bold, 16],
   ListPlot[
    Map[Tooltip[#, ToString[Round@#[[2]]] <> "%"] &,
     Transpose[{Range[n], #}] & /@ seqData[n], {2}], Frame -> True,
    Axes -> False, PlotStyle -> PointSize[Large], ImageSize -> 200,
    PlotRange -> If[n != 2, {{0, 5}, {0, 100}}, All]],
   Map[Tooltip[#, ToString[#[[2]]] <> "%"] &,
    Transpose[{Range[n], #}] & /@ seqData[n], {2}]}, {n, 4}]]


  • Prev by Date: Re: symbolic Variance - Integration
  • Next by Date: Re: Interactive 2d zoom and some Dynamic questions
  • Previous by thread: Re: Part ([[...]]) and span (;;)
  • Next by thread: Global Fitting multiple equations to multiple