matplotlib ti中的Latex和文本

2024-09-29 17:13:39 发布

您现在位置:Python中文网/ 问答频道 /正文

我试图显示一个标题为普通文本和两个Latex命令的图像:

plt.imshow(w1subtracted2, origin='lower',
          extent=[l_max, -l_max, -b_max, b_max],
          cmap = color_map)
plt.title('W1 disk and central $\pm2\textdegree$ subtracted', fontsize = 'small')
plt.xlabel(xlabel, fontsize = 'small')
plt.ylabel(ylabel, fontsize = 'small')
plt.savefig('w1subtracted2.png')

但我无法获得显示\pm\textdegree的标题以Latex样式显示。我怎么才能做到呢?在


Tags: 图像文本命令标题pltoriginmaxlatex
2条回答

似乎您使用的不是latex(usetext = True),而是简单的MathText。MathText中没有\textdegree。在

使用

plt.title(r'W1 disk and central $\pm2^\circ$ subtracted', fontsize = 'small')

应该给你

enter image description here

尝试通过终端运行代码,因为Spyder或Canopy无法处理Latex命令。在

相关问题 更多 >

    热门问题