반응형
/*******************************************************************************************************************
-- Title : [Py3.5] Boxplot w/ Matpoltlib
-- Reference : matplotlib.org/examples/pylab_examples/boxplot_demo.html
-- Key word : matplotlib boxplot 박스플롯 박스 플롯 box plot
*******************************************************************************************************************/
■ Figure
■ Script
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | import matplotlib.pyplot as plt import numpy as np # Source : http://matplotlib.org/examples/pylab_examples/boxplot_demo.html # ------------------------------ # -- fake up some data # ------------------------------ spread = np.random.rand(50) * 100 center = np.ones(25) * 50 flier_high = np.random.rand(10) * 100 + 100 flier_low = np.random.rand(10) * -100 data = np.concatenate((spread, center, flier_high, flier_low), 0) spread = np.random.rand(50) * 50 center = np.ones(25) * 25 flier_high = np.random.rand(10) * 50 + 100 flier_low = np.random.rand(10) * -100 data2 = np.concatenate((spread, center, flier_high, flier_low), 0) # ------------------------------ # -- Draw box plot # ------------------------------ # -- basic plot plt.boxplot([data, data2]) plt.show() # -- notched plot plt.figure() plt.boxplot([data, data2], 1) plt.show() # -- change outlier point symbols plt.figure() plt.boxplot([data, data2], 0, 'gD') plt.show() # -- don't show outlier points plt.figure() plt.boxplot([data, data2], 0, '') plt.show() # -- horizontal boxes plt.figure() plt.boxplot([data, data2], 0, 'rs', 0) plt.show() # -- change whisker length plt.figure() plt.boxplot([data, data2], 0, 'rs', 0, 0.9) plt.show() # -- fake up some more data spread = np.random.rand(50) * 100 center = np.ones(25) * 40 flier_high = np.random.rand(10) * 100 + 100 flier_low = np.random.rand(10) * -100 d2 = np.concatenate((spread, center, flier_high, flier_low), 0) data.shape = (-1, 1) d2.shape = (-1, 1) data = [data, d2, d2[::2, 0]] plt.figure() plt.boxplot(data) plt.show() |
반응형