# Is there a way to make an interactive plot so one can pan and zoom? [duplicate]

My googling efforts returned nothing so I thought I'd ask here. I often make a ListPlot[] with a huge array, and sometimes it has smaller features that I'd like to take a closer look at, but aren't very visible zoomed all the way out. Obviously I can just change the parameter PlotRange, but that's kind of cumbersome. Ideally, I'd like to be able to select a box around the part I want to zoom in on, and even more ideally maybe use my mousewheel to zoom in on where the cursor is, and be able to "grab" the plot to shift around where I'm looking at, when I'm zoomed in.

Most programs that plot things have this functionality, so I'm guessing MM must too. It seems like I might be able to do something similar using Manipulate cleverly (like, at least make sliders to control the zoom and center), but I don't see how to do it easily.

Is there any way?

• Probably you could include in your question the code of your current effort to use Manipulate on ListPlot ? – rhermans Sep 9 '14 at 15:10
• @rhermans, it was just speculation or a guess, I haven't tried that. Maybe the solution to what I want requires it, but I'm really asking if there's just kind of a built in module. – YungHummmma Sep 9 '14 at 15:16
• See for example this and other posts that appear if you search for "zoom." – C. E. Sep 9 '14 at 15:30
• @Pickett, thanks, that's what I meant by using Manipulate. But that's clearly a workaround. Does MM really not have this kind of functionality built in? – YungHummmma Sep 9 '14 at 16:04
• @YungHummmma I'm afraid not, not that I'm aware of anyway. – C. E. Sep 9 '14 at 16:47

The following will do what you ask, but likely not as expediently as you hoped for.

SeedRandom[42];
With[{data = RandomInteger[100, 100]},
With[{xspan = Length@data, yspan = Max@data},
DynamicModule[{mag, center, box, plotCenter},
Column[{
ClickPane[
Dynamic @ ListPlot[data,
PlotRange -> box[center],
Frame -> True,
Axes -> False,
ImageSize -> Medium],
(center = ##) &],
Dynamic @ Style[Row[{"Manificaton: ", mag, "  Centered at: ", center}], "SR"],
{1 :> (mag = 1; center = plotCenter),
1.5 :> (mag = 1.5),
2 :> (mag = 2)}]
}, Center],
Initialization :> (
mag = 1;
plotCenter = .5 {xspan, yspan};
center = plotCenter;
box[center_] :=
With[{x = center[[1]], y = center[[2]], dx = .5 xspan/mag, dy = .5 yspan/mag},
{{x - dx, x + dx}, {y - dy, y + dy}}]
)]]]


Clicking in the plot frame with center the plot at the point clicked on in the frame. Choosing a magnification value from the action menu will magnify the plot around the centered point.