matplotlib字体有完整的utf-8设置

时间:2017-02-04 04:33:18

标签: python matplotlib unicode utf-8

以下是previous question的扩展名。我错误地认为matplotlib中只支持一些 utf-8字符,至少DejaVu Sans建议使用here,而不是其他字符?具体来说,如果我不使用特殊的ballot x mark语法,则mathtext不会呈现,也不会进行常规复选标记。

# -*- coding: utf-8 -*-
%pylab inline
import numpy as np
from matplotlib import rcParams
import matplotlib.pyplot as plt
t = np.arange(0.0, 2.0, 0.01)
s = np.sin(2*np.pi*t)

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

plt.plot(t,s)
plt.text(1, -0.4, ur'$\u2718$', fontsize=20) # ballot x mark with mathtext
plt.text(1, -0.6, u'\u2713', fontsize=20) # check mark
plt.text(1, -0.8, ur'$\u2713$', fontsize=20) # check mark with mathtext
plt.xlabel(u'technologie\u00ebn in \u00b0C \u2713') # check mark after degrees C
plt.ylabel('volts (mV)')
plt.show()

产量

enter image description here

0 个答案:

没有答案