版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/Elvirangel/article/details/82453476
解决方案一:
默认是不可以显示中文,会将一个中文用两个框框替代。
解决方案参考:matplotlib图例中文乱码?.
导入下面的模块:
from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['SimHei']
解决方案二:
为了显示中文,需要设置FontProperties,代码编写如下:
# -*- coding: UTF-8 -*-
from matplotlib.font_manager import FontProperties