Python Matplotlib西里尔支持

Python Matplotlib西里尔支持,python,matplotlib,Python,Matplotlib,我想对matplotlib标签使用西里尔字母,因此我找到了一些示例,表明可以通过以下方式实现: matplotlib.rcdefaults() matplotlib.rcParams['font.family'] = 'fantasy' matplotlib.rcParams['font.fantasy'] = 'Times New Roman', 'Ubuntu','Arial','Tahoma','Calibri' 尝试此操作时,会出现以下错误: /usr/local/lib/python

我想对
matplotlib
标签使用西里尔字母,因此我找到了一些示例,表明可以通过以下方式实现:

matplotlib.rcdefaults()
matplotlib.rcParams['font.family'] = 'fantasy'
matplotlib.rcParams['font.fantasy'] = 'Times New Roman', 'Ubuntu','Arial','Tahoma','Calibri'
尝试此操作时,会出现以下错误:

/usr/local/lib/python2.7/dist-packages/matplotlib/font_manager.py:1279: UserWarning: findfont: Font family [u'fantasy'] not found. Falling back to Bitstream Vera Sans
  (prop.get_family(), self.defaultFamily[fontext]))

我正在将
matplotlib
prettyplotlib
一起使用Matpltlib无法找到字体,可能是字体格式错误,或者在
matplotlib/mpl data/fonts/
文件夹下不可用。尝试转换为
.ttf
,并使用此代码进行调试:

import matplotlib as mpl
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager

path = '/home/username/fantasy.ttf'
prop = font_manager.FontProperties(fname=path)
mpl.rcParams['font.family'] = prop.get_name()

fig, ax = plt.subplots()
ax.set_title('Test text', fontproperties=prop, size=40)
您还可以看到所有可用的字体:

import matplotlib.font_manager
print matplotlib.font_manager.findSystemFonts(fontpaths=None)

我会尝试一下,但“fantasy”不仅仅是字体家族的名字,在这个家族中,所有其他字体都是“Times New Roman”、“Ubuntu”、“Arial”、“Tahoma”、“Calibri”。