matplotlib 多条线注释
在matplotlib中,能不能显示一个多行的注释呢?
这是一个单行注释:
ax.annotate('line1', xy=(xi,yi), xycoords='data',
xytext=(-50, 30), textcoords='offset points',
arrowprops=dict(arrowstyle="->")
)
这是我想要做的(这个是通过图形界面编辑的):
1 个回答
5
其实很简单,只需要在一行的末尾加上“\n”就可以了:
'line1 \n line2 \n line3'
ax.annotate('line1 \n line2', xy=(timeNow, y), xycoords='data',
xytext=(-50, 30), textcoords='offset points',
arrowprops=dict(arrowstyle="->"),
verticalalignment='center',
horizontalalignment='center'
)