3

If I enter MatrixPlot[{{1, 2}, {3, 4}}],it shows:enter image description here

How can I combine this with a 2D slider,when I move the slider to a region,it could show me the value that correspond to the matrix?

Tsai
  • 31
  • 1

1 Answers1

2

By "slider", do you mean locator?

m = RandomInteger[{1, 100}, {10, 10}];

With[{eps = .1},
 DynamicModule[{p = {.5, .5}, lab},
  lab[{x_Integer, y_Integer}] :=
   Style[StringJoin[{"value: ",
      ToString[m[[Length[m] - y, x + 1]]]}], 16, Bold];
  LocatorPane[
   Dynamic[p],
   MatrixPlot[m,
    PlotLabel -> Dynamic[lab@Floor@p]],
   {{eps, eps}, Dimensions[m] - eps}]]]

enter image description here

BoLe
  • 5,819
  • 15
  • 33