Input axes attached to specific points in data coordinates?

I would like to be able to overlay several nested axes on top of the set of parent axes, something like this:

enter image description here

Ideally, I would like the anchor point of each set of nested axes to be fixed in the data coordinates, but for the size of the x, y axes to scale with the size of the figure, and not with the data scale.

For example, if I zoomed in on the area in the parent axes, I would like the insertion axis positions to move along with the data plotted on the parent axes, but for their areas and proportions to stay the same. The exact behavior I'm looking for is similar to a plot marker or an instance of matplotlib.Annotation . However, I would only agree to set the dimensions of the axes in the data coordinates.

I know that I can pass the rect argument to axes() to indicate the position and degree in the normalized coordinates of the shapes. However, I need my axes to snap to specific points in the data coordinates.

I also tried to do 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 does not have the desired effect (the x, y borders of my child axis are now tied to the values ​​of the parent axis that I don’t want, and its position is still not in the data coordinates).

I also looked at various examples here , but none of them seem to do what I'm looking for, i.e. Let me indicate an arbitrary anchor point in the data coordinates.

Any ideas?

+6
source share
1 answer

Save the insertion axes as images, and then paste them onto a larger shape. See Adding a small image / image to a large graph in Matplotlib / Python .

0
source

Source: https://habr.com/ru/post/955842/


All Articles