python 中 matplotlib.pyplot 绘图中文乱码问题

python是自带可以显示中文的字体的,输入如下代码可以查看系统可用字体。

from matplotlib.font_manager import FontManager
fm = FontManager()
mat_fonts = set(f.name for f in fm.ttflist)
print(mat_fonts)

在代码中加入一下内容,就可以愉快的使用中文 label 和 legend 了。

import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif'] = ['Arial Unicode MS']



参考:https://blog.csdn.net/qq_32590631/article/details/80509741

©著作权归作者所有,转载或内容合作请联系作者
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

推荐阅读更多精彩内容