赞
踩
- #导入Excel数据studentshuju.xls的代码:
- import matplotlib.pyplot as plt
- import pandas as pd
- import xlrd
- import seaborn as sns
- df = pd.read_excel('C:\hadoop-2.8.4\studentshuju.xls')
- print (df)
-
-
- #做箱式图的代码:
- fig = plt.figure()
- ax = fig.add_subplot(1,1,1)
- ax.boxplot(df['age'])
- plt.show()
-
-
- #做散点图的代码:
- fig = plt.figure()
- ax = fig.add_subplot(1,1,1)
- x=df['xuhao']
- y=df['height']
- z=df['weight']
- ax.scatter(x,y,c='b',marker='s',s=30)
- ax.scatter(x,z,c='y',marker='o',s=60)
- plt.show()
-
-
- #做饼图的代码:
- var = df.groupby(['sex']).sum().stack()
- t=var.unstack()
- type(t)
- x = t ['age']
- label1 = t.index
- plt.axis('equal')
- plt.pie(x,labels=label1,autopct='%1.1f%%')
- plt.show()
-
-
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。