MathGroup Archive 2012

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

Search the Archive

missing Tooltip for ArrayPlot etc. - workaround

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 on Windows, 64 bit)

With[{a = Table[i + Sin[i^2 + j^2], {i, 0, 4, .1}, {j, 0, 4, .1}]},
   ArrayPlot[a, ColorFunction -> "SunsetColors", PlotRangePadding ->
   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