我希望我的地块中的所有文字都是Times New Roman,所以我做了以下工作:
import matplotlib.pyplot as plt
plt.rcParams["font.family"] = "Times New Roman" # change default font
而且我只希望标签的'(x)'和'(z)'部分为斜体,所以我这样做了:
plt.xlabel('Underutilization $\it{(x)}$', labelpad=15)
plt.ylabel('Productivity $\it{(z)}$', labelpad=15)
但是,在绘图时,我最终得到的是Times New Roman中的'Unutiltilization',而在斜体的sans serif(Python的默认值)中是'(x)'。与ylabel相同。
我该如何补救?
$
符号内的文本由matplotlib的mathtext(除非您使用的是LaTex)决定,并由rcParam
mathtext.fontset
控制,documentation中用[]概述了这些内容>]
mathtext.fontset:“ dejavusans”(默认)“ dejavuserif”,“ cm”(现代计算机),“ stix”,“ stixsans”或“ custom”