Maybe you can use the custom function in this link or this post:
DragZoomPlot[expr_, {var_, lo_, hi_}, opts : OptionsPattern[]] :=
DynamicModule[{image = Plot[expr, {var, lo, hi}, opts], start, end,
xrange, yrange},
EventHandler[
Dynamic[
Show[start; image,
Epilog ->
If[ValueQ[start], {Opacity[0],
EdgeForm[Directive[Black, Dashed]],
Rectangle[start, MousePosition["Graphics"]]}, {}]]],
{"MouseDown" :> (start = MousePosition["Graphics"]),
"MouseUp" :> (end = MousePosition["Graphics"];
If[MatchQ[start, {_Real, _Real}] && MatchQ[end, {_Real, _Real}],
xrange = Prepend[Sort[{start[[1]], end[[1]]}], var];
yrange = Sort[{start[[2]], end[[2]]}];
image =
If[start[[1]] === end[[1]] || start[[2]] === end[[2]],
Plot[expr, {var, lo, hi}, opts],
Plot[expr, Evaluate[xrange], PlotRange -> Evaluate[yrange],
opts]]]; start =.)}
]]
DragZoomPlot[Sin[1/x] x, {x, -0.5, 0.5}, PlotPoints -> 100]
The following code can enlarge the figure in the rectangle drawn by the left button, and right click to restore the original figure:
dynamicShow[graphic_, opt___] :=
Module[{range = PlotRange[graphic]},
DynamicModule[{x1 = range[[1, 1]], x2 = range[[1, 2]],
y1 = range[[2, 1]], start, end, y2 = range[[2, 2]], x, y, k = 1},
EventHandler[
Dynamic[Show[graphic,
If[k == 2 && ValueQ[{start}],
Graphics@{Opacity[0], EdgeForm[Directive[Red, Thick]],
Rectangle[start, MousePosition["Graphics"]]}, {}],
Epilog ->
Inset[Panel[
Style[graphic /. (PlotRange ->
x__) :> (PlotRange -> {MinMax@{x1, x2},
MinMax@{y1, y2}}), opt, Magnification -> 0.25],
ImageSize -> {100, 70}],
Offset[{-2, -2}, Scaled[{1, 1}]], {Right,
Top}]]], {{"MouseDown",
1} :> {start = MousePosition["Graphics"], k++}, {"MouseUp",
1} :> (end = MousePosition["Graphics"];
If[k == 1, {},
If[start[[1]] === end[[1]] ||
start[[2]] ===
end[[2]], {{x1, x2}, {y1, y2}} =
range, {x1, y1} = start; {x2, y2} = end]; k--];)
, {"MouseClicked",
2} :> ({{x1, x2}, {y1, y2}} =
range)}]]]
data2 = Block[{δ = 0.3, γ = 0.5, ω = 1.25},
Reap[NDSolve[{x''[t] + δ x'[t] - x[t] +
x[t]^3 == γ Cos[ω t], x[0] == 0, x'[0] == 0,
WhenEvent[Mod[t, (2 π)/ω] == 0,
Sow[{x[t], x'[t]}]]}, {}, {t, 0, 100000},
MaxSteps -> ∞]]][[-1, 1]];
s = ListPlot[data2, ImageSize -> Medium,
PlotStyle -> PointSize[0.004], PlotRange -> {{-1.5, 1.5}, All}];
s // dynamicShow
