I'd like to be able to overlay multiple inset axes on top of a set of parent axes, something like this:
Ideally, I'd like the anchor point of each set of inset axes to be fixed in data coordinates, but for the x,y extent of the axes to scale with figure size rather than the scale of the data.
For example, if I zoomed in on a region in the parent axes, I'd want the positions of the inset axes to move together with the data plotted in the parent axes, but for their areas and aspect ratios to stay the same. The exact behaviour I'm looking for is something similar to a plot marker or a matplotlib.Annotation
instance. However, I'd settle for just being able to set the extent of the axes in data coordinates.
I'm aware that I can pass the rect
argument to axes()
to specify the position and extent in normalized figure coordinates. However, I need my axes to be anchored to specific points in data coordinates.
I've also tried doing something like this:
from matplotlib import pyplot as pp
fig,parent_ax = pp.subplots(1,1)
parent_ax.set_xlim(0,1)
parent_ax.set_ylim(0,1)
# desired axis bounding box in data coordinates
rect = (0.1,0.2,0.2,0.3)
child_ax = axes(rect)
# apply transformation to data coordinates of parent axis
child_ax.set_transform(parent_ax.transData)
which doesn't have the desired effect (the x,y limits of my child axis are now coupled to those of the parent axis, which I don't want, and its position is still not in data coordinates).
I've also looked at the various examples here, but none of them seem to do quite what I'm looking for, i.e. allow me to specify an arbitrary anchor point in data coordinates.
Any ideas?
draw_event
and on every draw relocate/rescale everything as you want. – Unemploymentloc=
spec for positioningAxisArtist
s etc. is not useful to me. I'm still keen to avoid writing complicated callbacks to do something that seems like it ought to be possible using transformations. – Lawrencedraw_event
with a sensible short-circut to prevent infinite loops). What you want is some what orthogonal to the way the library is designed. – Unemployment