matplotlib中的斜体符号? [英] italic symbols in matplotlib?
本文介绍了matplotlib中的斜体符号?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我试图在情节标签中将伽玛符号设为斜体,但不知道该怎么做?
I'm trying to get the gamma symbol to be italicised in a plot label but can't figure out how to do it?
我认为这应该工作(但不行)
I thought this should work (but doesn't)
plt.xlabel(r'$\mathit{\Gamma}$$^{*}$')
我应该添加我正在使用Helvetica字体,所以不想切换到tex模式,例如这对我不起作用:
I should add I am using the Helvetica font, so don't want to switch into tex mode, e.g. this doesn't work for me:
import matplotlib
import matplotlib.pyplot as plt
plt.rcParams['font.family'] = "sans-serif"
plt.rcParams['font.sans-serif'] = "Helvetica"
plt.rcParams['text.usetex'] = True
plt.plot(range(5), range(5))
plt.title('$\Gamma + \mathit{\Gamma}$', fontsize=40)
plt.show()
谢谢,
马丁
推荐答案
在 '$$' 之间写入强制解释文本的文本.
Write the text between '$$' that forces the text to be interpreted.
import matplotlib.pyplot as plt
plt.plot(range(5), range(5))
plt.title('$\it{text you want to show in italics}$')
plt.show()
这篇关于matplotlib中的斜体符号?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文