What I'm actually trying to do is to elaborate [this question][1]. I'd like to use Pane
with scrollbars enabled to explore large (sparse) matrices like this one:
![enter image description here][2]
Here is what I have so far using some ideas from [this answer][3]:
A = ExampleData[{"Matrix", "HB/west0381"}, "Matrix"] // Normal;
{n, m} = Dimensions@A;
mp = MatrixPlot[A, ImageSize -> 9 m, Mesh -> All];
DynamicModule[{trans, ij, mpos},
trans[{x_, y_}] := {Clip[Floor[n - y] + 1, {1, n}],
Clip[Floor@x + 1, {1, m}]};
Pane[
Show[mp, ImagePadding -> {{40, 20}, {20, 20}},
Epilog -> Text[
Framed[
Dynamic[(ij = trans@MousePosition["Graphics", {0, 0}]) ->
A[[Sequence @@ ij]]], Background -> White],
Dynamic[MousePosition["Graphics", {0, 0}]],
{1, -1}
]~Style~Larger
],
{500, 500},
Scrollbars -> True]
]
The result is
![enter image description here][4]
Now about the problems
1. The main trouble is that it does not correctly translate coordinates
for horizontal scrolling. If we don't touch the horizontal scrollbar
everything is fine:
![enter image description here][5]
But if I slide horizontally the label shifts and falls outside the
visible area. It looks like a Mma bug.
2. The second funny thing is that if I remove //Normal
from the first row then MatrixPlot
produces the following:
![enter image description here][6]
which seems to be the second bug.
3. And finally the issue which is due to my confusion with Dynamic
things. In the code I use MousePosition["Graphics", {0, 0}]
twice (can this be the reason for the item 1 from above?). When I tried to save this coordinates in a variable I had no luck. But there must be a way to do this.
Any suggestions?
[1]: MatrixPlot with Tooltips
[2]: https://i.sstatic.net/X6rNA.png
[3]: http://mathematica.stackexchange.com/a/2524/219
[4]: https://i.sstatic.net/SLaS3.png
[5]: https://i.sstatic.net/RP8aZ.png
[6]: https://i.sstatic.net/JIChf.png