Best way to create an inset axes with "shared" scales.


I am trying to figure out the best way to create an inset axis on a plot, but where one inset axis shares the same scale as the main axis.

Basically, I want something like the inset axes in, but where the x-axis of the inset axis is aligned and has the same scale as the main x-axis i.e., rather than specifying the relative co-ordinates of the inset axis in the figure, I want to specify the x extents in the data units of the main axis. The y-scale will be independent.

I though this might be related to "sharing" axes, but that is something else. In a sense, I want the inset axes to be a "view" of the larger axis.

I can do all this by calculating where the new axis should go, etc. in figure units, but wondered if there was a "best practise" for doing this so that I can guarantee that the inset axis will always be aligned with the main figure axis, even if the figure is resized etc.

Also, are there standard functions for converting co-ordinates from the data co-ordinates of the axes to relative figure co-ordinates etc.? (I am sure the proper names for each co-ordinate system, and the transformation etc. are described somewhere, but I have not found it yet.)

Thanks for any suggestions or guidance.