使用 LaTeX 在 Python 中使用 LaTex "~" 符号

Using LaTex "~" symbol in Python using LaTeX

请查看我用来生成图像的代码片段。最后,我想用图像写一段文字。在那里,我想使用通过 rc 参数设置的 TeX 渲染设置的“~”符号。但是,当我 运行 代码时,它甚至不打印 "tilde" 符号。任何想法,我怎样才能合并这个?谢谢。

from matplotlib import rc
rc('text', usetex=True)
rc('font',size=size_axislabels,**{'family':'serif','serif':['Times'],'weight' : 'bold'})
bbox_props = dict(boxstyle="Square,pad=0.3", fc="w", ec="0.5", lw=3)    
........
........
ax.text(90, 41, r"Distance: $~$ 500 pc", ha="center", va="center", size=20,transform=ax.get_transform('galactic'),
        bbox=bbox_props)

对post我的评论作为回答:

问题是您没有为波形符使用正确的 latex 命令。在数学模式下,您可以使用 $\sim$ 来写波浪号。