Wolfram Research

DragZoomPlot

Contributed by: Jon McLoone

Source Notebook

A version of Plot which allows you to zoom into the plot using the mouse

ResourceFunction["DragZoomPlot"][f,{x,xmin,xmax}]

generates a plot of f as a function of x from xmin to xmax which can be zoomed into using the mouse.

Details and Options

Click and drag within the resulting plot to cause it change the PlotRange.
Click in the plot to reset to the original PlotRange.

Examples

Basic Examples

Click and drag to select regions of a plot which you wish to see enlarged.

In[1]:=
ResourceFunction["DragZoomPlot"][Sin[1/x] x, {x, -0.5, 0.5}, PlotPoints -> 100]
Out[1]=

Options

All options for Plot are supported.

In[2]:=
ResourceFunction["DragZoomPlot"][Sin[1/x] x, {x, -0.5, 0.5}, Background -> Yellow]
Out[2]=

Possible Issues

You cannot use the mouse to resize the result of DragZoomPlot, so it is is necessary to use ImageSize to control the size.

In[3]:=
ResourceFunction["DragZoomPlot"][Sin[1/x] x, {x, -0.5, 0.5}, ImageSize -> 100]
Out[3]=

Resource History