首页 > 解决方案 > matplotlib 的自定义 Latex 字体

问题描述

我正在尝试更改 Latex 方程式字体,因此我使用了自定义字体,并且尝试了各种系统字体,但问题是我更改了字体系列,仅更改了数字而不更改字符(在我的示例中为 x 和 y)本身。

from matplotlib import  rcParams
from matplotlib import pyplot as plt
import matplotlib
from matplotlib.font_manager import FontProperties

import matplotlib.font_manager
print([f.name for f in matplotlib.font_manager.fontManager.ttflist])

rcParams['mathtext.fontset'] = 'custom'
rcParams['mathtext.rm'] = 'STIXGeneral'
#rcParams['mathtext.rm'] = 'Corbel'
##rcParams['mathtext.rm'] = 'Arial'

matplotlib.rcParams.update({'font.size': 21})
fig, ay = plt.subplots()
plt.title("$x+y=21$")
plt.show()

STIX通用字体输出

牛腿字体输出

Arial 字体输出

有什么想法吗?我正在尝试让 Stix2 数学工作。

标签: python-3.xmatplotlib

解决方案


推荐阅读