Pixel placement of text

[I'm Cc:ing people since the mailing list forwarder seems to be
  working really slowly.]

Hi Bill,

You can even throw all the magic into one function like this:

def const_offset(x,y):

[...]

And then just add a transform=const_offset(x,y) parameter wherever
you want one.

This will waste some memory by creating a new transform object every
time, which could matter if your plots contain lots of text labels.
You can simply create the transformation once and then use it when
needed.

Here's a better solution adapted from John Hunter's and Eric Firing's
posts and putting the transformation magic into a function:

pxoff.py (704 Bytes)

Thanks to all who contributed to this thread concerning how to draw something such as text at an offset relative to a data point, with the offset in screen coordinates so that it stays constant with zooming etc.

The result in svn is a new function in transforms:

def offset_copy(trans, fig=None, x=0, y=0, units='inches'):
     '''
     Return a shallow copy of a transform with an added offset.
       args:
         trans is any transform
       kwargs:
         fig is the current figure; it can be None if units are 'dots'
         x, y give the offset
         units is 'inches', 'points' or 'dots'
     '''

This works for all transformations including polar; an example is given in examples/transoffset.py, also in svn.

All transformations now have shallowcopy and deepcopy methods; the shallowcopy method is used in offset_copy. The deepcopy methods were there all along in _transforms.cpp, with functionality apparently partly duplicated in the copy_bbox_transform function in transforms.py. John added copy_bbox_transform_shallow to transforms.py as part of this thread. I would like to remove it, together with copy_bbox_transform, on the grounds that these functions probably have not been used by anyone except during the last few days, and their functionality is available in a much more general way via the Transformation deepcopy and shallowcopy methods.

Any objections?

Thanks.

Eric