matplotlib作图中文显示问题

时间:2023-03-09 07:11:15
matplotlib作图中文显示问题
def set_ch():
from pylab import mpl
mpl.rcParams['font.sans-serif'] = ['FangSong'] # 指定默认字体
mpl.rcParams['axes.unicode_minus'] = False # 解决保存图像是负号'-'显示为方块的问题
set_ch()

 几经摸索,各种转码都不好使,解决方案就是把以上代码放进源码或者import进去即可。