This thread might be helpful.
http://thread.gmane.org/gmane.comp.python.matplotlib.general/16373
Take a look at the above thread and see if it fits your need.
However, it became tricky if your axes adjust its position (e.g.,
aspect=1) during the drawing time.
The example below will be helpful in those case (you need recent
version of matplotlib for this, see if your axes has
"set_axes_locator" method), but this requires some knowledge on how
mpl works.
import matplotlib.transforms
class InsetPosition(object):
def __init__(self, parent, lbwh):
self.parent = parent
self.lbwh = lbwh # position of the inset axes in the
normalized coordinate of the parent axes
def __call__(self, ax, renderer):
bbox_parent = self.parent.get_position(original=False)
trans = matplotlib.transforms.BboxTransformTo(bbox_parent)
bbox_inset = matplotlib.transforms.Bbox.from_bounds(*self.lbwh)
bb = matplotlib.transforms.TransformedBbox(bbox_inset, trans)
return bb
ax = gca()
ax.set_aspect(1.)
axins = axes([0, 0, 1, 1])
ip = InsetPosition(ax, [0.5, 0.1, 0.4, 0.2])
axins.set_axes_locator(ip)
IHTH,
-JJ
On Wed, Apr 1, 2009 at 8:22 AM, oyarsa the old <[email protected]> wrote:
> Hello,
>
> I am new to matplotlib and pylab.
> I have an image plotted with imshow/contour, or even just a coordinate
> system plotted with axis.
>
> I need to plot smaller contours/images on them at selected pixels. The only
> way I can figure how to do that is using axes. However, axes is defined on
> normalised coordinates which cover the entire window, whereas the axis of
> the main figure is drawn within it, with some margin.
>
> My problem is how to get the correct coordinates for plotting each of the
> smaller figures ? The easiest way to do so would be to get the normalised
> coordinates of the rectangle which is drawn by axis. Is there a way to get
> that?
>
> Thanks
> Mohan.
>
> ------------------------------------------------------------------------------
>
> _______________________________________________
> Matplotlib-users mailing list
> [email protected]
> https://lists.sourceforge.net/lists/listinfo/matplotlib-users
>
>
------------------------------------------------------------------------------
_______________________________________________
Matplotlib-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/matplotlib-users