# 下面是求五数概括的是程序
import plotly.plotly
import plotly.graph_objs as go
matrix = [13,15,16,16,19,20,20,21,22,22,25,25,25,25,30,33,33,35,35,35,35,36,40,45,46,52,70]
min_matrix = min(matrix) #找出数组中的最大值
max_matrix = max(matrix) #找出数组中的最小值
range = max_matrix - min_matrix #求出范围
# print (range)
x = range/4
temp = max_matrix - x
len_matrix = len(matrix)
Q3 = matrix[0]
i = 0
# 开始求Q3
while len_matrix > 0:
len_matrix = len_matrix - 1
if temp >= matrix[i]:
if Q3 <= matrix[i]:
Q3 = matrix[i]
# print (Q3)
i = i + 1;
# print (Q3)
# 结束求Q3
# 开始求Q2
Q2 = Q3 #Q2的值比Q3小,先将Q3赋值给Q2
temp = min_matrix + x
# print (temp)
i = 0
len_matrix = len(matrix)
while len_matrix > 0:
len_matrix = len_matrix - 1
if temp <= matrix[i]:
if Q2 >= matrix[i]:
Q2 = matrix[i]
# print (i)
i = i + 1;
# print (Q2)
# 结束求Q2
# 求Median
temp = min_matrix + 2*x
Median = Q2
min = abs(Median - temp)
len_matrix = len(matrix)
i = 0
while len_matrix > 0:
len_matrix = len_matrix - 1
if abs(matrix[i] - temp) < min:
min = abs(matrix[i] - temp)
r = i
i = i + 1
Median = matrix[r]
# 结束Median
print (min_matrix)
print (Q2)
print (Median)
print (Q3)
print (max_matrix)
data = [
go.Box(
y=[min_matrix, Q2, Median, Q3, max_matrix] # 9个数据
)
]
plotly.offline.plot(data) # 离线绘图
#by杨帆(四川师范大学,email:yangfanx26@foxmail.com)