MatrixPlot
is very nice to have a first look of data, I would like to have a MatrixPlot
with tooltips for each value. I tried adding Tooltip
to all the values but it didn't work. My matrix is not very big (~20x25), so each square is visible.
EDIT: This is the version I did using the answer of Heike:
matPlot[matWithTooltips_, opts : OptionsPattern[]] :=
With[{dim = Dimensions[matWithTooltips],
mat = matWithTooltips /. Tooltip[a_, ___] :> a},
DynamicModule[{pt = {0, 0}, ij, xy, label, direction},
direction[mxy_] := 1 - 2 Boole[Thread[mxy > dim/2]];
LocatorPane[Dynamic[pt],
Dynamic[
xy = Floor[pt];
ij = {dim[[1]], 1} + Cross[xy];
label = If[And @@ Thread[1 <= ij <= dim],
{{FaceForm[], EdgeForm[{Thick, LightGray}], Rectangle[xy]},
Text[
Framed[Replace[
Extract[matWithTooltips, ij], {Tooltip[a_, b_] :> b,
Tooltip[a_] :> a}], Background -> White],
direction[xy] + xy,
-1.2 direction[xy]]},
{}];
MatrixPlot[mat, Epilog -> label, opts]],
AutoAction -> True,
Appearance -> None]]]
The main improvement is that it can receive a matrix with its own tooltips in the data.
Thanks to all for the help.