配置字体系列

可以显式设置为给定的字体样式(例如“serif”、“sans-serif”或“monospace”)选择的字体系列。

在下面的示例中,对于sans-serif字体样式,我们只允许使用一个字体系列(Tahoma)。默认族设置为字体系列rcparam,例如:

rcParams['font.family'] = 'sans-serif'

对于font.family,您可以设置一个按顺序查找的字体样式列表:

rcParams['font.sans-serif'] = ['Tahoma', 'DejaVu Sans',
                               'Lucida Grande', 'Verdana']
from matplotlib import rcParams
rcParams['font.family'] = 'sans-serif'
rcParams['font.sans-serif'] = ['Tahoma']
import matplotlib.pyplot as plt

fig, ax = plt.subplots()
ax.plot([1, 2, 3], label='test')

ax.legend()
plt.show()

关键词:matplotlib代码示例,codex,python plot,pyplot Gallery generated by Sphinx-Gallery