|
#encoding=utf-8
'''
Created on 2017年8月
@author: acer
'''
import pandas as pd
catering_sale='I:/pyanalysis/catering_sale.xlsx'
data=pd.read_excel(catering_sale,index_col='time')
import matplotlib.pyplot as plt
plt.rcParams['font.sans-serif']=['SimHei']
plt.rcParams['axes.unicode_minus']=False
plt.figure()
p=data.boxplot()
x=p['flites'][0].get_xdata()
y=p['flites'][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.08,y[i]))
plt.show()
运行后提示错误:
Traceback (most recent call last):
File "I:\Users\acer\eclipse-workspace\data_analyze\src\day1\pystatsmodels.py", line 18, in <module>
x=p['flites'][0].get_xdata()
TypeError: 'AxesSubplot' object has no attribute '__getitem__'
那位大神帮忙看下,跪谢!
|
|