Python 如何在matplotlib轴中写入latex特殊字符$\bar{T}$?

Python 如何在matplotlib轴中写入latex特殊字符$\bar{T}$?,python,matplotlib,plot,latex,Python,Matplotlib,Plot,Latex,我想将latex数学模式符号$\bar{T}$写入使用matplotlib制作的绘图的轴标签中。声明不支持数学模式,所以我尝试了 plt.xlabel(r'$\displaystyle \={T}$',fontsize=12) 及 这就产生了错误 matplotlib.pyparsing.ParseFatalException: Expected end of math '$' $\displaystyle \={T}$ (at char 0), (line:1, col:1) 及 是否有办

我想将latex数学模式符号$\bar{T}$写入使用matplotlib制作的绘图的轴标签中。声明不支持数学模式,所以我尝试了

plt.xlabel(r'$\displaystyle \={T}$',fontsize=12)

这就产生了错误

matplotlib.pyparsing.ParseFatalException: Expected end of math '$'
$\displaystyle \={T}$ (at char 0), (line:1, col:1)


是否有办法使用matplotlib在轴标签中写入此符号?我已经能够编写其他latex轴标签,但我从未使用过这些标签中的任何一个,您链接的文档页描述调用latex来提供格式化文本,但是matplotlib有自己的内置数学表达式解析器,可以很好地处理大多数latex数学命令,没有实际运行外部latex命令。除非您专门将matplotlib安装设置为使用Latex的外部安装,否则您仍然使用内置数学解析器,它可以处理
\bar{}
很好:

plt.plot(range(5), range(5))
plt.xlabel(r'$\bar{T}$',fontsize=12)
plt.show()
    raise ParseFatalException(msg + "\n" + s)
matplotlib.pyparsing.ParseFatalException: Expected end of math '$'
$\={T}$ (at char 0), (line:1, col:1)
>>> 
plt.plot(range(5), range(5))
plt.xlabel(r'$\bar{T}$',fontsize=12)
plt.show()