python - Aligning annotations in matplotlib -
i'm having trouble figuring out how align 2 annotations. want label located @ midpoint of bar connecting 2 arrows. i'm hoping there way of specifying transform allow me use similar units when specifying arrows , label. appreciated!! 
using following code, if adjust offset can produce acceptable results (as long don't change settings such size of figure).
i've tried specifying 'axes points' xycoords , textcoords, thinking arma , armb in points.
f = plt.figure() ax = f.add_subplot(1,1,1) f.subplots_adjust(bottom=0.2) offset = -0.05 # create arrow annotation ann = ax.annotate("", (0.6, -0.1), xycoords=('data', 'axes fraction'), xytext=(.8, -0.1), textcoords=('data', 'axes fraction'), arrowprops=dict(arrowstyle="<->", connectionstyle="bar,arma=-20,armb=-20,angle=0,fraction=0.0")) # add label center of bar ann_label = ax.annotate('foo', (.7, -0.1+offset), xycoords=('data', 'axes fraction'), bbox=dict(boxstyle='round', fc='white'), ha='center', va = 'center')
Comments
Post a Comment