You can do it, it just takes a bit of knowledge about how different
transformations are used under the hood:
import matplotlib.transforms as mtransforms
import matplotlib.pyplot as plt
# Basic plot of single point. Adjust limits to give space
x0,y0 = 4,5
plt.plot(x0, y0, 'o')
plt.ylim(-10, 20)
plt.xlim(0, 15)
# Grab axes object so we can get the tranformation used to
# transform data points into axes coords
ax = plt.gca()
# Create a transform that moves to the data point and then
# adds an offset of 10 up (I'm not sure if it's points or pixels)
# Transforms can be combined using just the simple '+'
trans = ax.transData + mtransforms.Affine2D().translate(0, 10)
plt.text(x0, y0, 'Testing', horizontalalignment='center',
verticalalignment='center', transform=trans, clip_on=True)
# Now do one 15 right
trans2 = ax.transData + mtransforms.Affine2D().translate(15, 0)
plt.text(x0, y0, 'Testing2', horizontalalignment='left',
verticalalignment='center', transform=trans2, clip_on=True)
plt.show()
I hope this helps. Let me know if anything is unclear.
Ryan
···
On Sun, Jan 3, 2010 at 1:02 AM, Phillip M. Feldman <pfeldman@...2440...> wrote:
Ah. It sounds as though one must consider the scale of the map, and
then choose these offsets so that the text falls near but not too near
the marker. It would be great if one could specify the text offsets in
units of the font size rather than in units of map distance.
--
Ryan May
Graduate Research Assistant
School of Meteorology
University of Oklahoma