I made a simple 2D plot, but I can't zoom in-out on the figure. I tried many ways. But none gave any results.

Click anywhere + drag the mouse zooms in/out on the point where the mouse was clicked. Ctrl + drag toggles zooming rectangle (from Szabolcs). Shift + drag pans the plot (from Heike). Alt shows coordinates (only when over the plot so that other global Alt-functionality (like Alt+C+L to remove output) can be still used). *) Double click anywhere resets the plot (from kguler). Resize handler at bottom right corner to manipulate ImageSize (does not change aspect ratio). Ctrl + resize also changes aspect ratio.".

I attach a picture shows that it is impossible to zoom in and out.

enter image description here.

  • $\begingroup$ You could use PlotRange to choose what part of the image you want to see. $\endgroup$ – bill s Sep 7 '17 at 23:42

The graphics interactions you quote only apply to 3D plots. 2D plot's do not have such support built-in. But do not dispair, Heike's answer here can easily be adapted to your list plot.

data = Accumulate /@ RandomReal[{-1., 1.}, {3, 250}];
DynamicModule[{range, ref, range0, fac = 2/3},
  range = range0 = {{0, 250}, MinMax[data]};
    Dynamic @
        PlotRange -> range,
        Filling -> Axis,
        ImageSize -> Large],
   {"MouseDown" :> 
     (ref = MousePosition["GraphicsImageScaled"]; 
      range0 = range), 
    "MouseDragged" :> 
      (* pan *)
      (range = 
        range0 + 
          (ref - MousePosition["GraphicsImageScaled"]) 
            (range0[[All, 2]] - range0[[All, 1]])),
    "MouseClicked" :>
        (* zoom in *)
        CurrentValue["AltKey"], (* Cmnd on OS X *)
        range = 
          (range - MousePosition["Graphics"])*fac + MousePosition["Graphics"], 
        (* zoom out *)
        range = 
          (range - MousePosition["Graphics"])/fac + MousePosition["Graphics"]]}]]

When first evaluated it looks like this.


After paning and zooming it can look like this.



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