matplotlim柱状图
import numpy as np import matplotlib matplotlib.use("TKAgg") import matplotlib.pyplot as plt d=np.arange(0,10,0.1) datas=np.array( [24,10,13,36]) subjects=['香蕉','苹果','辣椒','其他'] plt.rcParams['font.family'] = 'SimHei' #调整中文乱码 plt.figure() #plt.pie(datas,labels=subjects) plt.bar(np.arange(len(subjects)), datas,width=0.15,tick_label=subjects,label='小红') plt.bar(np.arange(len(subjects)) +0.15, datas * 1.2,width=0.15,label='小张') plt.legend() plt.title("水果数量比对") plt.show()