#导入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()
pycharm做箱式图、散点图、饼图
于 2022-04-07 19:39:36 首次发布
![](https://img-home.csdnimg.cn/images/20240711042549.png)