Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

This question already has an answer here:

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}];
MatrixPlot[TestArray]
share|improve this question

marked as duplicate by Mr.Wizard Jul 30 '13 at 5:58

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

    
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}]. –  Artes Jun 29 '13 at 10:05
    
@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? –  UKa Jun 29 '13 at 10:09
1  
Duplicate of: mathematica.stackexchange.com/q/7142/5 –  rm -rf Jun 29 '13 at 12:44

1 Answer 1

Have you explored the capabilites of Manipulate yet?

Manipulate[
 MatrixPlot[TestArray,
  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}];
Manipulate[
 Row[{
   MatrixPlot[
    TestArray,
    ImageSize  -> 200,
    PlotRangePadding -> 0,
    ColorFunction -> cf],
   MatrixPlot[
    TestArray,
    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.

share|improve this answer
    
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? –  UKa Jun 29 '13 at 10:17
    
@uka something similar here which could be easily adapted. Look up Locators too, for mouse input. –  cormullion Jun 29 '13 at 10:25

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