import pandas as pd import os import matplotlib.pyplot as plt data=pd.read_excel('C:/Users/Administrator/Desktop/demo/data/catering_sale.xls',index_col='日期') plt.rcParams['font.sans-serif']=['SimHei']#正常显示中文 plt.rcParams['axes.unicode_minus']=False#正常显示负号 plt.figure(figsize=(8,8)) p=data.boxplot(return_type='dict') x=p['fliers'][0].get_xdata() y=p['fliers'][0].get_ydata() y.sort() for i in range(len(x)): if i>0: plt.annotate(y[i],xy=(x[i],y[i]),xytext=(x[i]+0.05-0.8/(y[i]-y[i-1]),y[i])) else: plt.annotate(y[i],xy=(x[i],y[i]),xytext=(x[i]+0.8,y[i])) plt.show()