1. Box Plot
![](https://velog.velcdn.com/images/rkdgg0/post/8d9dba27-55ca-4bb2-9a5d-e5f325f4ed07/image.png)
1) Simple Plot Graph
samples = [1,7,9,16,36,39,45,45,46,48,51,100,101]
tmp_y = [1]*len(samples)
import matplotlib.pyplot as plt
plt.figure(figsize=(12,6))
plt.scatter(samples, tmp_y)
plt.grid()
plt.show()
![](https://velog.velcdn.com/images/rkdgg0/post/1a8d3cb7-f97e-4fd5-a6e0-c6231fdde37d/image.png)
2) Box Plot 지표 찾기
# 중앙값, Q2
np.median(samples)
# 45.0
# Q1
np.percentile(samples, 25)
# 16.0
# Q3
np.percentile(samples, 75)
# 48.0
# iqr
iqr = np.percentile(samples, 75) - np.percentile(samples, 25)
iqr *1.5
# 48.0
3) 그래프에 지표 그리기
q1 = np.percentile(samples, 25)
q2 = np.median(samples)
q3 = np.percentile(samples, 75)
iqr = q3 - q1
upper_fence = q3 + iqr*1.5
lower_fence = q1 - iqr*1.5
plt.figure(figsize=(12,4))
plt.scatter(samples, tmp_y)
plt.axvline(x = q1, color='black')
plt.axvline(x = q2, color='red')
plt.axvline(x = q3, color='black')
plt.axvline(x = upper_fence, color='black', ls='dashed')
plt.axvline(x = lower_fence, color='black', ls='dashed')
plt.grid()
plt.show()
![](https://velog.velcdn.com/images/rkdgg0/post/1bc27ad3-2d7f-4d2e-b3ac-a5c85db0f1ed/image.png)