0
我試圖使用matplotlib
庫創建直方圖。缺少matplotlib.pyplot標籤中的波蘭語字符(不管使用UTF-8)
我將編碼設置爲UTF-8,但某些波蘭字符(不是全部,只有一些)缺失。 我試過玩encode
和decode
,但沒有成功。
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import sys
reload(sys)
sys.setdefaultencoding('utf8')
import matplotlib.pyplot as plt
#sampleData
data=[[ 0.13837092, 0.14755699, 0.17719047, 0.1998352 ],
[ 0.19318216, 0.15863521, 0.17136143, 0.18979461]]
n, bins, patches = plt.hist(data, facecolor='green')
# I've tried also adding: .encode('UTF8') and .decode('UTF8'), but without success
plt.xlabel("Wartości ą, ć, ę, ł, ń, ó, ś, ź, ż.")
plt.ylabel("Prawdopodobieństwo ą, ć, ę, ł, ń, ó, ś, ź, ż.")
plt.title("Tytuł ą, ć, ę, ł, ń, ó, ś, ź, ż.")
plt.grid(True)
plt.savefig("sampleHist.png")
plt.clf()
http://stackoverflow.com/questions/13338550/typing-greek-letters-etc-in-python-plots – Jakub
的編碼是好的。但是您使用的字體不包含這些字符。重複的問題解釋瞭如何更改matlabplot中使用的字體。 –