pandas绘图中文乱码解决方案

      pandas绘图的时候中文会变成方块。解决方法就是选择支持中文的字体即可。

import matplotlib.font_manager as fm

# 解决中文字体问题
# mac字体路径:/System/Library/Fonts/
cn_font = fm.FontProperties(fname='/System/Library/Fonts/PingFang.ttc')
plt.legend(prop=cn_font)

猜你喜欢

转载自aeolus1983.iteye.com/blog/2441301