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()View Code
标签:matplotlim,plt,matplotlib,label,柱状图,subjects,np,datas From: https://www.cnblogs.com/wdfrog/p/18014644