# Zooming a portion of a plot [duplicate]

I want to zoom/exaggerate a portion of the following plot for t between 1 and 2, such that the zoomed portion is also within the main plot.

x[t_] = Sin[50 t]/t + Cos[t];
y[t_] = Sin[30 t]/t^2 + Cos[t^2];
P1 = Plot[x[t], {t, 0, 2 \[Pi]}, PlotStyle -> Blue];
P2 = Plot[y[t], {t, 0, 2 \[Pi]}, PlotStyle -> Red];
Show[P2, P1]


• Define "highlight". May 3, 2017 at 16:10
• Echo David's comment about what is meant by highlight May 3, 2017 at 16:56
• By highlight, I mean to zoom a particular portion so that it is clearly visible.
– Jee
May 3, 2017 at 18:36
• May 4, 2017 at 7:11

x[t_] = Sin[50 t]/t + Cos[t];
y[t_] = Sin[30 t]/t^2 + Cos[t^2];
sub = Plot[{x[t], y[t]}, {t, 1, 2}, PlotStyle -> {Blue, Red},
PlotRange -> All]
Plot[{x[t], y[t]}, {t, 0, 2 Pi}, PlotStyle -> {Blue, Red},
Epilog -> Inset[sub, Scaled[{.3, .55}], Scaled[{0, 0}], 3],
PlotRange -> {-12, 12}, PlotRangeClipping -> False]


Show[P2, P1,
Epilog -> {Opacity[0.5], Yellow, Rectangle[{1, -2}, {2, 2}]}]


The highlighted region is under the plots of x[t] and y[t], so the plots are not covered by the plots like Epilog did.

In:

Remove[x, y, t, highlight]
x[t_] = Sin[50 t]/t + Cos[t];
y[t_] = Sin[30 t]/t^2 + Cos[t^2];
P1 = Plot[x[t], {t, 0, 2 \[Pi]}, PlotStyle -> Blue];
P2 = Plot[y[t], {t, 0, 2 \[Pi]}, PlotStyle -> Red];

HighlightRegion[f1_, f2_, a_, b_] :=
Module[{t, xyMin, xyMax, highlight, fs},
fs = {f1, f2};
xyMin =
fs // Map[NMinValue[{#[t], a <= t <= b}, t] &] // {a, Min[#]} &;
xyMax = fs //
Map[NMaxValue[{#[t], a <= t <= b}, t] &] // {b, Max[#]} &;
highlight = Graphics[{Yellow, Rectangle[xyMin, xyMax]}, Axes -> True]
]
highlight = HighlightRegion[x, y, 1, 2];
Show[highlight, P2, P1]


Out: