# How to scale inset such that it takes up the specific region of a plot

Consider two plots, one of which will contain the other as an inset.

 inset = Plot[ x, {x, 1, 2}
, Frame -> True
]
A = Plot[ x^2 , {x, 1, 2}
, Epilog -> { Inset[ inset,  {1.5, 2.5},  {1, 1}, 0.5]}
]


This code works perfectly with one limitation. Let's say I want to place the inset that spans from 1.5 to 1.9 in the scale of x-axis in the main panel while keeping the aspect ratio of the inset constant. To achieve this effect, I had to manually controls the fourth option, which scales the inset object. Is there anyway to automate this process?

From How to make Inset graphics maintain relative sizes when combined the sizing itself is easy if we rasterize the inset plot:

Manipulate[
p1 = Plot[x, {x, 1, 2}, Frame -> True] // Rasterize;
p2 = Plot[x^2, {x, 1, lim}, GridLines -> {{1.5, 1.9}}];
size = (1.9 - 1.5)/(#2 - #) & @@ PlotRange[p2][];
Show[p2, Epilog -> {Inset[p1, {1.5, 2.5}, {0, 0}, Scaled[size]]}],
{lim, 2, 5}
] However dealing the the resizing of the non-rasterized Graphics is tricky. How should the tick labels outside the plot range be handled?

Using LLlAMnYP's functions from How to align coordinate systems of Inset and enclosing Graphics? we could write:

Manipulate[
p1 = Plot[x, {x, 1, 2}, Frame -> True];
p2 = Plot[x^2, {x, 1, lim}, GridLines -> {{1.5, 1.9}}];
size = printerPointsPlotRange[p2][]/realPlotRange[p2][]*(0.4);
Show[p2, Epilog -> {Inset[Show[p1, ImageSize -> size], {1.5, 2.5}, {Left, Bottom},
Automatic]}],
{lim, 2, 5}
] This fits the inset including its tick labels neatly between the grid lines.