饼图 堆叠图 从文件加载数据 Matplotlib饼图 import matplotlib.pyplot as plt import matplotlib # 设置中文字体 matplotlib.rcParams['axes.unicode_minus'] = False matplotlib.rcParams['font.sans-serif'] = ['Microsoft YaHei'] matplotlib.rcParams['font.family']='sans-serif' slices = [7,2,2,13] activities = ['睡觉','吃饭','工作','玩耍'] cols = ['c','m','r','b'] plt.pie(slices, labels=activities, colors=cols, startangle=90, shadow= True, explode=(0, 0.1, 0, 0), autopct='%1.1f%%') plt.title('编程字典-matplotlib教程') plt.show() 堆叠图 从文件加载数据