Affines and ax.text()

Hi All,

I'm having a problem using Affines to generate a rotated XY plot. The
code below works with the exception of the ax.text(...) statement which
doesn't put the text where I think it should go.

Anyone know what I'm doing wrong?


from pylab import figure, show
from matplotlib.numerix import arange
from matplotlib.transforms import Value, Affine

line_props = dict(linewidth=0.5, color='black', linestyle='-')
fig = figure()
ax = fig.add_axes([0.1, 0.1, 0.8, 0.8])

# Create Affine with 45 degree rotation
temp_orig = Value(-20)
theta_orig = Value(-20)
temp_width = Value(120)

scale = (ax.bbox.ur().x() - ax.bbox.ll().x())/temp_width
tx = ax.bbox.ll().x() - (temp_orig*scale + theta_orig*scale)
ty = ax.bbox.ll().y() - (temp_orig*scale - theta_orig*scale)
affine = Affine(scale, Value(0)-scale, scale, scale, tx, ty)

# Plot (rotated) gridlines
temp_min = -70
temp_max = 40
theta_min = -20
theta_max = 90

temp = arange(temp_min, temp_max, 10)
theta = arange(theta_min, theta_max, 10)

for t in temp:
    ax.plot((t, t), (theta_min, theta_max), transform=affine,

for t in theta:
    ax.plot((temp_min, temp_max), (t, t), transform=affine,

# Plot a small square around (0,20) - this works OK
ax.plot((-1, -1, 1, 1, -1), (19, 21, 21, 19, 19), transform=affine)

# Plot text at (0, 20)- should be in the same place as the small square,
but isn't
ax.text(0, 20, 'Test', transform=affine)




Visit our website at

Roke Manor Research Ltd, Roke Manor, Romsey, Hampshire SO51 0ZN, UK.

The information contained in this e-mail and any attachments is proprietary to
Roke Manor Research Ltd and must not be passed to any third party without
permission. This communication is for information only and shall not create or
change any contractual relationship.