挑战黑道霸少,碧螺春属于,董洁老公照片
1 import matplotlib.pyplot as plt 2 from matplotlib.font_manager import fontproperties 3 import numpy as np 4 import pandas as pd
1 def drawmultboxpic(input_dict,y_label): 2 dict_list_length = [] 3 for item in input_dict: 4 temp_length = len(input_dict[item]) 5 dict_list_length.append(temp_length) 6 # 获取最长列表长度 7 max_length = max(dict_list_length) 8 # 每个列表在后面追加none 9 for item in input_dict: 10 diff_length = max_length - len(input_dict[item]) 11 if diff_length > 0: 12 for i in range(diff_length): 13 input_dict[item].append(none) 14 # else: 15 # print('{}文件列表长度最长'.format(item)) 16 # 绘制箱型图 17 zhfont = fontproperties(fname='c:/windows/fonts/simsun.ttc', size=16) 18 data = pd.dataframe.from_dict(input_dict) 19 data.boxplot(widths=0.3,figsize=(30,15),fontsize=16) 20 plt.xlabel(u'煤质文件名称', fontproperties=zhfont) 21 plt.ylabel(y_label, fontproperties=zhfont) 22 plt.title(y_label, fontproperties=zhfont) 23 # plt.axis([0, 6, 0, 90]) 24 plt.grid(axis='y', ls='--', lw=2, color='gray', alpha=0.4) 25 plt.grid(axis='x', ls='--', lw=2, color='gray', alpha=0.4) 26 imgname = 'e:\\' + y_label + '.png' 27 plt.savefig(imgname, bbox_inches = 'tight') 28 # plt.show()
1 """ 2 【函数说明】获取箱体图特征 3 【输入】 input_list 输入数据列表 4 【输出】 out_list:列表的特征[下限,q1,q2,q3,上限] 和 error_point_num:异常值数量 5 【版本】 v1.0.0 6 【日期】 2019 10 16 7 """ 8 def boxfeature(input_list): 9 # 获取箱体图特征 10 percentile = np.percentile(input_list, (25, 50, 75), interpolation='linear') 11 #以下为箱线图的五个特征值 12 q1 = percentile[0]#上四分位数 13 q2 = percentile[1] 14 q3 = percentile[2]#下四分位数 15 iqr = q3 - q1#四分位距 16 ulim = q3 + 1.5*iqr#上限 非异常范围内的最大值 17 llim = q1 - 1.5*iqr#下限 非异常范围内的最小值 18 # llim = 0 if llim < 0 else llim 19 # out_list = [llim,q1,q2,q3,ulim] 20 # 统计异常点个数 21 # 正常数据列表 22 right_list = [] 23 error_point_num = 0 24 value_total = 0 25 average_num = 0 26 for item in input_list: 27 if item < llim or item > ulim: 28 error_point_num += 1 29 else: 30 right_list.append(item) 31 value_total += item 32 average_num += 1 33 average_value = value_total/average_num 34 # 特征值保留一位小数 35 out_list = [average_value,min(right_list), q1, q2, q3, max(right_list)] 36 # print(out_list) 37 out_list = save1point(out_list) 38 return out_list,error_point_num
如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复
Python爬虫:Request Payload和Form Data的简单区别说明
浅谈Python中threading join和setDaemon用法及区别说明
Python3-异步进程回调函数(callback())介绍
python继承threading.Thread实现有返回值的子类实例
Python中使用threading.Event协调线程的运行详解
网友评论