2015-01-14 2 views
1
내가 these 예제가에 의해 달성 될 수 있음을 보여주는 발견, 그래서 내가 matplotlib 레이블 키릴 문자를 사용하려면

:하기 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])) 

matplotlibprettyplotlib을 사용하고 있습니다.

답변

3

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) 
+0

나는 그것을 시도주지하지만 '환상'은하지 않습니다 만 'Times New Roman', 'Ubuntu', 'Arial', 'Tahoma', 'Calibri'와 같은 다른 모든 글꼴이있는 글꼴 패밀리 이름입니다. – bozhidarc

+0

그것이 작동하는 솔루션에 감사드립니다! – bozhidarc