テキスト表示の際、図中の座標値を指定

関数 ax.text(x,y,txt) とすると、描画するデータを基にした(x,y)座標にテキストを表示する。
関数 ax.text(x,y,txt,transform=ax.transAxes) とすると、図の上での(x,y)座標にテキストを表示する。

#!/usr/bin/env python


import matplotlib.pyplot as plt


def plot():
    fig = plt.figure()
    ax = fig.add_subplot(1,1,1)    

    ax.plot([1,2,3,0.5])

    ax.text(0.3,0.1,"ABC",transform=ax.transAxes)
    ax.text(0.4,0.3,"DEF",transform=ax.transAxes)
    ax.text(0.6,0.6,"GHI",transform=ax.transAxes)
    ax.text(0.7,0.8,"JKL",transform=ax.transAxes)
    
    plt.savefig('test.png')


if __name__=="__main__":
    plot()

※参照: http://matplotlib.org/users/transforms_tutorial.html#axes-coordinates