'''- 'line' : line plot (default)
- 'bar' : vertical bar plot
- 'barh' : horizontal bar plot
- 'hist' : histogram
- 'box' : boxplot
- 'kde' : Kernel Density Estimation plot
- 'density' : same as 'kde'
- 'area' : area plot
- 'pie' : pie plot
- 'scatter' : scatter plot
- 'hexbin' : hexbin plot'''
df.plot(kind='bar')# 条形图
df.plot(kind='box')# 箱型图
df = DataFrame({'height':np.random.normal(170,size=60,scale=15),'age':np.random.normal(20,size=60,scale=2)},dtype=np.uint8)
df['height'].plot(kind='hist',density =True)# density = True y坐标使用密度,与密度曲线对应;False时为次数统计Frequency
df['height'].plot(kind='density',color='red')
频率条形图与密度曲线图
age weight height
df = DataFrame({'height':np.random.normal(170,size=1000,scale=15),'age':np.random.normal(20,size=1000,scale=2)},dtype=np.uint8)defchange_self(x):if x <145:
x += np.random.randint(0,50)if x >200:
x -= np.random.randint(0,50)return x
df['height']= df['height'].map(change_self)
df.plot(x='age',y='height',kind='scatter')
defchange_self(x):
y =((x-100)*2-30)/2+ np.random.randint(0,50)- np.random.randint(0,30)while y <35:
y += np.random.randint(0,50)while y >125:
y -= np.random.randint(0,40)return y
df['weight']= df['height'].map(change_self)
df.plot(x='height',y='weight',kind='scatter')