运行下列代码:
import matplotlib.pyplot as pltedu = [0.2515,0.3724,0.3336,0.0368,0.0057]labels = ['中专','大专','本科','硕士','其他']plt.pie(x=edu,labels=labels,autopct='%.1f%%')plt.show()
会出现:
RuntimeWarning: Glyph 20013 missing from current font. font.set_text(s, 0.0, flags=flags)
这是matplotlib绘制的图里面不能正常显示中文,提示警告
matplotlib绘图中文警告
【解决方法】:
import matplotlib.pyplot as pltedu = [0.2515,0.3724,0.3336,0.0368,0.0057]labels = ['中专','大专','本科','硕士','其他']plt.pie(x=edu,labels=labels,autopct='%.1f%%')plt.rcParams['font.sans-serif']=['SimHei']#显示中文标签#plt.rcParams['font.sans-serif']=['Microsoft YaHei'] #写这个也可以显示中文标签plt.show()