>>>>> "Eric" == Eric Firing <[EMAIL PROTECTED]> writes:
Eric> Attached is a simple example that illustrates the method. Eric> What threw me off last night is that the Eric> copy_bbox_transform() function was not doing what I Eric> expected. I don't know yet whether this is because of a bug Eric> or a misunderstanding on my part, but in any case, the Eric> example provides an alternative. (It is not valid for any Eric> bbox transform, but I think it will be fine in normal use What I just wrote to Eric offlist is that copy_bbox_transform is a deep copy, and so all the references of the matplotlib transforms are lost (see http://matplotlib.sf.net/matplotlib.transforms.html for details on the reference semantics of mpl transforms). What we want is a shallow copy -- this is like Eric's get_bbox_transform below but also handles nonlinear transformation like log I added to svn: def copy_bbox_transform_shallow(trans): """ return a shallow copy of the bbox transform -- the Values are retained by reference but the transform is copied. This allows you to copy a transform, set a new offset to it, but not lose the value reference semantics """ inbox = trans.get_bbox1() outbox = trans.get_bbox2() typex = trans.get_funcx().get_type() typey = trans.get_funcy().get_type() newtrans = get_bbox_transform(inbox, outbox) newtrans.get_funcx().set_type(typex) newtrans.get_funcy().set_type(typey) return newtrans Eric> cases.) The basic method can be used on any artist by Eric> calling set_offset on that artist's transform. More precisely, on a shallow copy of any artist's transform. You don't want to set the offset of the artist's transform itself, since that will move the artist itself. Eric, how about adding a helper method to matplotlib.transforms call "relative_to", something like trans = relative_to(artist, pointsx, pointsy) you can get dpi from artist.figure.dpi to construct the right points->pixels offset. Then you could do trans = relative_to(line, -5, 10) ax.text(x, y, 'hi', transform=trans) This may not be the perfect API, but it should give you the idea of providing a very simple interface to users to build these transforms for offsets. JDH ------------------------------------------------------------------------- Take Surveys. Earn Cash. Influence the Future of IT Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys -- and earn cash http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users