利用matplotlib绘图时出现错误:UserWarning: Glyph 20540 (\N{CJK UNIFIED IDEOGRAPH-503C}) missing from current font. FigureCanvasAgg.draw(self)

前提:在绘制图时需要在横纵坐标处标写中文。具体如图中横坐标中文未显示,而是一个方块代替:

解决:原文链接
需要添加如下代码:

import matplotlib
matplotlib.rc("font", family='Microsoft YaHei')
posted @ 2024-08-30 11:12  yiyou_liangdian  阅读(2573)  评论(0)    收藏  举报