From: John H. <jdh...@ac...> - 2006-07-28 17:47:18
|
>>>>> "Eric" == Eric Firing <ef...@ha...> writes: Eric> I think that what you want to do requires something like the Eric> mechanism in QuiverKey: a derived artist with a draw method Eric> that figures out at draw time where to put the text; I don't Eric> think there is any other way to handle zooming while keeping Eric> the screen separation from a data point fixed. You can do this using offsets -- see matplotlib.axis.XTick._get_text1. This is how tick labeling is done (a point offset from an x location in data coords and a y location in axis coords). Here is an example -- you have to copy the default data transform so that the offset doesn't affect the figure data from matplotlib.transforms import Value, translation_transform,blend_xy_sep_transform from pylab import figure, show fig = figure() ax = fig.add_subplot(111) points = 7 pad = fig.dpi*Value(points/72.0) # poor man's copy trans = blend_xy_sep_transform(ax.transData, ax.transData) # to the left and above offset = translation_transform(Value(-1)*pad, pad) trans.set_offset( (0,0), offset) ax.plot([1,2,3]) t = ax.text(1,2, 'hi', transform=trans) show() |