I have a MatrixPlot output which I would like to zoom around in, drawing boxes that define a zoom region with my mouse. These things are all fairly standard in Labview... surely Mathematica must have a similar set of abilities?

For an example matrix, we can write:

TestArray = Array[RandomInteger[{0, 1}] &, {100, 100}];
  • $\begingroup$ Having your MatrixPlot done, click once on it and pressing a small orange rectangle at the bottom of the plot, drag it to zoom your plot. Use simply RandomInteger[1, {100, 100}] instead of Array[RandomInteger[{0, 1}] &, {100, 100}]. $\endgroup$ – Artes Jun 29 '13 at 10:05
  • $\begingroup$ @Artes Thanks for the tip about not using Array. However, I meant being able to use my mouse to define a window within the graphic, which we then clip and zoom to. Is this possible? $\endgroup$ – UKa Jun 29 '13 at 10:09
  • 1
    $\begingroup$ Duplicate of: mathematica.stackexchange.com/q/7142/5 $\endgroup$ – rm -rf Jun 29 '13 at 12:44

Have you explored the capabilites of Manipulate yet?

  Mesh -> m,
  ColorFunction -> cf,
  PlotRange -> {{xmin, xmax}, {ymin, ymax}}],
 {xmin, 1, 50, 1}, {ymin, 1, 50, 1},
 {xmax, 51, 100, 1}, {ymax, 51, 100, 1},
 {m, 1, 50},
 {cf, ColorData["Gradients"]}

matrix plot explorer

Here's a slightly more mouse-y one:

coordsToRowColumns[pt_, mag_, w_, h_] := 
 Module[{rmin, cmin, rmax, cmax},
  rmin =  pt[[1]];
  cmin = h - pt[[2]] ;
  rmax = pt[[1]] + mag ;
  cmax = cmin + mag;
  {{cmin, cmax}, {cmin, cmax}}]
TestArray = RandomReal[1, {100, 100}];
    ImageSize  -> 200,
    PlotRangePadding -> 0,
    ColorFunction -> cf],
    ImageSize  -> 400,
    PlotRange -> coordsToRowColumns[pt, mag, 100, 100],
    AspectRatio -> 1,
    ColorFunction -> cf
 {{pt, {0, 100}} , Locator},
 {{mag, 50, "Magnification"}, 1, 100},
 {cf, ColorData["Gradients"]},
 ControlPlacement -> {Bottom, Top}]

zoomy mag thing

I prefer this kind of view, sometimes, over a simple zoom in/out style. Here, you can see an overview of where you are, so you don't get lost, and you you can change the magnification without changing the location. There's room for improvement, though.

  • $\begingroup$ Actually, I've just been playing around with Manipulate. However, what I'm really looking to do is to quickly define a zoom region with my mouse. Could I perhaps click somewhere and then have Manipulate provide me a slidebar to zoom in and out centered on that clicked point? That seems like it would be within the range of Mathematica's capabilities? $\endgroup$ – UKa Jun 29 '13 at 10:17
  • $\begingroup$ @uka something similar here which could be easily adapted. Look up Locators too, for mouse input. $\endgroup$ – cormullion Jun 29 '13 at 10:25

Not the answer you're looking for? Browse other questions tagged or ask your own question.