15 python數據可視化(精講箱圖)
00 載入擴展庫
import numpy as np
import matplotlib.pyplot as plt
01 箱圖
x=np.random.rand(2000)*10
plt.boxplot(x)
plt.grid(axis='y',ls=':',c='b')

02 patch_artist的使用
x=np.random.rand(2000)*10
plt.boxplot(x,patch_artist=True)
plt.grid(axis='y',ls=':',c='b')

03 whis的使用
x=np.random.rand(2000)*10
plt.boxplot(x,whis=0.1,patch_artist=True,showfliers=False)
plt.grid(axis='y',ls=':',c='b')
plt.ylim(0,10)

04 showfliers的使用
x=np.random.rand(1000)*10
y=np.array([20,22,25])
x1=np.hstack([x,y])
plt.boxplot([x,x1])
plt.grid(axis='y',ls=':',c='b')

x=np.random.rand(1000)*10
y=np.array([20,22,25])
x1=np.hstack([x,y])
plt.boxplot([x,x1],showfliers=False)
plt.grid(axis='y',ls=':',c='b')
plt.ylim(0,25)
05 vert的使用
x=np.random.rand(2000)*10
plt.boxplot(x,vert=False,whis=0.1,
patch_artist=True,showfliers=False)
plt.grid(axis='x',ls=':',c='b')
plt.xlim(0,10)

06 sym的使用
x=np.random.rand(1000)*10
y=np.array([20,22,25])
x1=np.hstack([x,y])
plt.boxplot([x,x1],sym='^')
plt.grid(axis='y',ls=':',c='b')
plt.ylim(0,25)

07 notch的使用
x=np.random.rand(2000)*10
plt.boxplot(x,notch=True)
plt.grid(axis='y',ls=':',c='b')
08 修改坐標標識
x=np.random.rand(2000)*10
plt.boxplot(x,notch=True)
plt.grid(axis='y',ls=':',c='b')
plt.xticks([1],['box'])
工程師必備
- 項目客服
- 培訓客服
- 平臺客服
TOP




















