def draw_vert_avg(ax, statistics): print('draw_vert_avg') ymax = ax.get_ylim()[1] a_hits_df = stat_tools.find_first_hits(statistics, acc.acc_requirement) a_mean = a_hits_df['end_time'].mean() a_line = ax.vlines(a_mean, ymin=0, ymax=ymax, colors=c.bg_dot_color, linewidth=3, path_effects=[c.white_outline]) _set_zorder(a_line) best_params = _find_best_params(statistics) best_stat = statistics.select_by_values(best_params) b_hits_df = stat_tools.find_first_hits(best_stat, acc.acc_requirement) b_mean = b_hits_df['end_time'].mean() b_color = next(c.iter_fg_dot_color()) b_line = ax.vlines(b_mean, ymin=0, ymax=ymax, colors=b_color, linewidth=3, path_effects=[c.white_outline]) _set_zorder(b_line) _add_2_important([(a_mean, 0), (b_mean, 0)])
def draw_group(fn, ax, stat_objs, on=True, label=None, **kwargs): colors = c.iter_fg_dot_color() if on else c.iter_fg_dot_off_color() iter_label = iter(label) if label is not None else None for stat_obj in stat_objs: color = next(colors) obj = fn(ax, stat_obj, color=color, **kwargs) if iter_label: _set_label(obj, label=next(iter_label))
def draw_group(ax, fn, hit_df, groupby, on=True, label=False, **kwargs): colors = c.iter_fg_dot_color() if on else c.iter_fg_dot_off_color() for param_val, local_df in hit_df.groupby(groupby).__iter__(): color = next(colors) xs = local_df['end_time'].values obj = fn(ax, xs, color=color, **kwargs) if label: _set_label(obj, label=param_val)
def draw_group(fn, ax, statistics, param, on=True, label=False, **kwargs): param_vals = statistics.params_combination[param].unique() colors = c.iter_fg_dot_color() if on else c.iter_fg_dot_off_color() for param_val in param_vals: local_stat = statistics.select_by_values({param: param_val}) color = next(colors) obj = fn(ax, local_stat, color=color, **kwargs) if label: _set_label(obj, label=param_val)
def draw_parm_lines(ax, statistics, param, max=False): param_vals = statistics.params_combination[param].unique() y_mode = 'avg_max' if max else 'avg' for param_val, color in zip(param_vals, c.iter_fg_dot_color()): print(f'\tparam_val = {param_val}') local_stat = statistics.select_by_values({param: param_val}) for avg_x, avg_y in stat_tools.gen_log_avg_dots(local_stat, y_mode=y_mode): lines = ax.plot(avg_x, avg_y, c=color) lines[0].set_label(param_val)
def draw_box_plot(ax, hostname_all, hit_times_all): print('\tdraw_box_plot') colors = c.iter_fg_dot_color() box_plot = ax.boxplot(hit_times_all, vert=False, labels=hostname_all, patch_artist=True) for box, flier, color in zip(box_plot['boxes'], box_plot['fliers'], colors): box.set_facecolor(color) flier.set_markerfacecolor(color)
def draw_best_dots(ax, statistics, hits=False): print('draw_best_dots') color = next(c.iter_fg_dot_color()) best_params = _find_best_params(statistics) best_stat = statistics.select_by_values(best_params) xs, ys = stat_tools.get_log_dots(best_stat) path = ax.scatter(xs, ys, c=color, label='best') _set_zorder(path) if hits: _draw_hits(ax, best_stat, color=color)
def draw_grouped_avg(ax, startup_time_df, type_label, time_label='startup_time', sections=2): mean_df = startup_time_df.groupby(type_label).mean().reset_index() dfs = _split_df(mean_df, by=time_label, sections=sections) for df, color in zip(dfs, c.iter_fg_dot_color()): ax.scatter(df[type_label].values, df[time_label].values, c=color, edgecolor='white', s=90)
def draw_group(axs, fn, hit_df, groupby, on=True, label=False, **kwargs): colors = c.iter_fg_dot_color() if on else c.iter_fg_dot_off_color() itera_ax = iter(axs) for param_val, local_df in hit_df.groupby(groupby).__iter__(): color = next(colors) ax = next(itera_ax) xs = local_df['end_time'].values obj = fn(ax, xs, color=color, **kwargs) if label: _set_label(obj, label=param_val) # text annotate in legend form ax.legend(title=f'{groupby} = {param_val}', labels=[], labelspacing=0.)
def draw_box_plot(ax, statistics, by_param): df = stat_tools.find_first_hits(statistics, acc.acc_requirement) df = df.dropna(axis='index') colors = c.iter_fg_dot_color() data = [] param_vals = [] for param_val, local_df in df.groupby(by_param).__iter__(): data.append(local_df['end_time']) param_vals.append(param_val) box_plot = ax.boxplot(data, vert=False, labels=param_vals, notch=False, patch_artist=True) for box, flier, color in zip(box_plot['boxes'], box_plot['fliers'], colors): box.set_facecolor(color) flier.set_markerfacecolor(color) ax.set(xlabel='end_time(s)', ylabel=by_param)
def draw_bars(ax, values_df, groupby, data_row, on=True, label=False, annotate='{:.2f}'): colors = c.iter_fg_dot_color() if on else c.iter_fg_dot_off_color() gooups_iter = iter_gooups(values_df, groupby, data_row=data_row) print(f'\tdata_row = {data_row}') # print(values_df) for xs, hight, bar_width, _label in gooups_iter: rects = ax.bar(x=xs, height=hight, color=next(colors), width=bar_width, label=_label if label else None) _draw_annotate(ax, rects, annotate)