1.调用itchat API加载数据
import itchat
import pandas as pd
import matplotlib.pyplot as plt
itchat.login()
2.加载数据
mps=pd.DataFrame(itchat.get_mps(update=True))
mps_extra=mps[['NickName','City','Province','Signature']]
data_loc=mps['Province'].value_counts()
3.绘图
plt.pie(data/len(data),labels=data.index,autopct='%1.1f%%')
from pylab import mpl
#解决中文乱码问题
mpl.rcParams['font.sans-serif'] = ['FangSong']
mpl.rcParams['axes.unicode_minus'] = False
plt.show()