11.all_boxplot - wwj-2017-1117/graph GitHub Wiki

画箱形图(1)

import numpy as np import matplotlib.pyplot as plt

np.random.seed(100) data = np.random.normal(size=1000, loc=0, scale=1) plt.boxplot(data) plt.show()

画箱形图(2),改变异常点的形状,sym='>'

import numpy as np import matplotlib.pyplot as plt

np.random.seed(100) data = np.random.normal(size=1000, loc=0, scale=1) plt.boxplot(data, sym='>') plt.show()

画箱形图(3),调整异常值的范围 whis = 1.5

import numpy as np import matplotlib.pyplot as plt

np.random.seed(100) data = np.random.normal(size=1000, loc=0, scale=1) plt.boxplot(data, sym='>', whis=0.6) plt.show()

画箱形图(4),同时画出多个箱形图

import numpy as np import matplotlib.pyplot as plt

np.random.seed(100) data = np.random.normal(size=(1000, 4), loc=0, scale=1) labels = ['A', 'B', 'C', 'D'] plt.boxplot(data, labels=labels) plt.show()