Matplotlib/Seaborn中文字体乱码问题解决-Windows+Mac

Windows

1.改变全局字体

from pylab importmpl

mpl.rcParams['font.sans-serif']=['FangSong']
mpl.rcParams['axes.unicode_minus']=False

import matplotlib

matplotlib.rcParams['font.family']='SimHei'#黑体'STSong'仿宋

2.改变用到的字体,增加fontproperties属性

plt.xlabel('纵轴:时间',fontproperties='SimHei',fontsize=20)

 Mac

import matplotlib.pyplot as plt
import seaborn as sns

plt.rcParams['font.family'] = ['Arial Unicode MS'] #用来正常显示中文标签
plt.rcParams['axes.unicode_minus'] = False #用来正常显示负号

sns.set_style('whitegrid',{'font.sans-serif':['Arial Unicode MS','Arial']})

 

你可能感兴趣的:(Matplotlib/Seaborn中文字体乱码问题解决-Windows+Mac)