0
$\begingroup$

This question already has an answer here:

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.

$\endgroup$

marked as duplicate by m_goldberg plotting Sep 8 '17 at 1:39

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.

  • $\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
1
$\begingroup$

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.

SeedRandom[2];
data = Accumulate /@ RandomReal[{-1., 1.}, {3, 250}];
DynamicModule[{range, ref, range0, fac = 2/3},
  range = range0 = {{0, 250}, MinMax[data]};
  EventHandler[
    Dynamic @
      ListLinePlot[data,
        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" :>
      Which[
        (* zoom in *)
        CurrentValue["AltKey"], (* Cmnd on OS X *)
        range = 
          (range - MousePosition["Graphics"])*fac + MousePosition["Graphics"], 
        (* zoom out *)
        CurrentValue["ShiftKey"], 
        range = 
          (range - MousePosition["Graphics"])/fac + MousePosition["Graphics"]]}]]

When first evaluated it looks like this.

plot

After paning and zooming it can look like this.

zoomed

$\endgroup$

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