matplotlib 多行注释

AJN*_*AJN 2 python matplotlib

是否可以在 matplotlib 中显示多行注释?

这是单行注释:

ax.annotate('line1', xy=(xi,yi),  xycoords='data',
                    xytext=(-50, 30), textcoords='offset points',
                    arrowprops=dict(arrowstyle="->")
                    )
Run Code Online (Sandbox Code Playgroud)

这就是我需要做的(这是以图形方式编辑的):

在此输入图像描述

AJN*_*AJN 5

就像在行尾添加“\n”一样简单:

'第1行\n第2行\n第3行"

ax.annotate('line1 \n line2', xy=(timeNow, y),  xycoords='data',
            xytext=(-50, 30), textcoords='offset points',
            arrowprops=dict(arrowstyle="->"),
            verticalalignment='center', 
            horizontalalignment='center'
            )
Run Code Online (Sandbox Code Playgroud)