You can add the parameter horizontalalignment='center'
. The documentation for Text Layout can be found here if you need it for future reference.
from matplotlib.text import Text
import matplotlib.pyplot as plt
fig = plt.figure()
fig.add_artist(Text(0.5, 0.5, text=r"Hello" "
" r"world!!!!!!!", horizontalalignment='center'))
plt.show()
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…