MathGroup Archive 2012

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

Search the Archive

missing Tooltip for ArrayPlot etc. - workaround

  • To: mathgroup at smc.vnet.net
  • Subject: [mg124419] missing Tooltip for ArrayPlot etc. - workaround
  • From: sibir <martin.rommel at gmail.com>
  • Date: Thu, 19 Jan 2012 05:09:35 -0500 (EST)
  • Delivered-to: l-mathgroup@mail-archive0.wolfram.com

People on the group have occasionally bemoaned the lack of support for
Tooltip with ArrayPlot and the like.
I was missing this handy functionality as well today and came up with
a workaround.
If somebody has a better solution or suggestions for improvement,
please post!
Of course, built-in support like for ListPlot would be the best.

Note, that my example below suffers from a lack of range checking for
the array indices. I minimize it by not having any PlotRangePadding,
but you can still get an error if you move the mouse pointer slowly
over the top or right edge. (I'm using 8.0.4.0 on Windows, 64 bit)

With[{a = Table[i + Sin[i^2 + j^2], {i, 0, 4, .1}, {j, 0, 4, .1}]},
 Dynamic@Tooltip[
   ArrayPlot[a, ColorFunction -> "SunsetColors", PlotRangePadding ->
None],
   a[[Sequence @@With[{pt =IntegerPart /@ MousePosition["Graphics",
{0, 0}]}, {Length[a] - pt[[2]], 1 + pt[[1]]}]]]
 ]
]



  • Prev by Date: Re: Question about function
  • Next by Date: BoxWhiskerChart and a Vertical Line on same graph
  • Previous by thread: Re: Tips for writing correct, non trivial Mathematica Libraries
  • Next by thread: BoxWhiskerChart and a Vertical Line on same graph