I'm trying to update the position of an annotation. If I add an annotation,
change it's position using set_position, I find the value of the position
(found using get_position) is updated, but the actual position on the
figure does not change. How can I actually change the position of the text
and starting point of the corresponding arrow?

Here's an example:

import matplotlib.pyplot as plt

data = [10, 8, 8, 5]

fig = plt.figure()
ax = fig.add_subplot(111)
ax.bar(range(len(data)),data)
ax.set_ylim(0,max(data)+2)
annotationPos1 = ax.annotate("Really long and large label",fontsize=12,
                         xy=(1.4,8),
                         xytext=(1.4,8.5),
                         arrowprops=dict(arrowstyle="->")
                         )

annotationPos2 = ax.annotate("Really long and large label",fontsize=12,
                             xy=(1.4,8),
                             xytext=(1.4,10.5),
                             arrowprops=dict(arrowstyle="->")
                             )

apos1before = annotationPos1.get_position()
annotationPos1.set_position((apos1before[0],apos1before[1]+2))
apos1after = annotationPos1.get_position()
apos2 = annotationPos2.get_position()
print apos1before,apos1after,apos2
plt.show()


Thanks, Yann
------------------------------------------------------------------------------
RSA(R) Conference 2012
Mar 27 - Feb 2
Save $400 by Jan. 27
Register now!
http://p.sf.net/sfu/rsa-sfdev2dev2
_______________________________________________
Matplotlib-users mailing list
Matplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users

Reply via email to