def get_box_plot(df: pd.DataFrame):

    def set_box_color(bp, color):
        plt.setp(bp['boxes'], color=color)
        plt.setp(bp['whiskers'], color=color)
        plt.setp(bp['caps'], color=color)
        plt.setp(bp['medians'], color=color)
    N = 5
    df_grouped = df.groupby(['title', 'it_ot'])
    df_grouped_mean = df_grouped.median().unstack()
    df_grouped_mean_metric = df_grouped_mean[METRICS[0]]
    df_grouped_mean['metricDiff'] = (df_grouped_mean_metric['output/target'] - df_grouped_mean_metric['input/target'])
    df_grouped_mean.sort_values(by=['metricDiff'], ascending=[True], inplace=True)
    sorted_titles = df_grouped_mean.reset_index()['title'].iloc[:N].to_list()
    df = df_grouped.filter((lambda x: x['title'].isin(sorted_titles).all()))
    df_grouped = df.groupby(['title', 'it_ot'])
    it_colors = {title: np.asarray(plt.get_cmap('tab20')((((2 * idx) + 1) / 20))) for (idx, title) in enumerate(sorted_titles)}
    ot_colors = {title: np.asarray(plt.get_cmap('tab20')(((2 * idx) / 20))) for (idx, title) in enumerate(sorted_titles)}
    (fig, ax) = plt.subplots(1, len(METRICS), figsize=(10, 4))
    for (plot_idx, metric) in enumerate(METRICS):
        width = 0.6
        inner_space = ((width * 2) / 3)
        outer_space = 2
        df_grouped_metric = df_grouped[metric].apply(list)
        df_ot_grouped = df_grouped_metric.loc[:, 'output/target']
        df_it_grouped = df_grouped_metric.loc[:, 'input/target']
        for (idx, title) in enumerate(sorted_titles):
            it_value = df_it_grouped.loc[title]
            bp_it = ax[plot_idx].boxplot(it_value, positions=[((idx * outer_space) - inner_space)], sym='', widths=width)
            set_box_color(bp_it, it_colors[title])
            ot_value = df_ot_grouped.loc[title]
            bp_ot = ax[plot_idx].boxplot(ot_value, positions=[((idx * outer_space) + inner_space)], sym='', widths=width)
            set_box_color(bp_ot, ot_colors[title])
        ax[plot_idx].tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
        ax[plot_idx].set_title(METRICS_TITLE[plot_idx], fontdict=dict(fontsize=9))
        ax[plot_idx].set_ylabel('mm', labelpad=2.0)
    custom_legend_lines = [Line2D([0], [0], color=color, lw=4) for color in ot_colors.values()]
    fig.legend(custom_legend_lines, ot_colors.keys(), loc='upper right', ncol=((len(custom_legend_lines) // 4) + 1))
    plt.tight_layout()
    plt.subplots_adjust(wspace=0.3, top=0.75)
def get_box_plot(df: pd.DataFrame):

    def set_box_color(bp, color):
        plt.setp(bp['boxes'], color=color)
        plt.setp(bp['whiskers'], color=color)
        plt.setp(bp['caps'], color=color)
        plt.setp(bp['medians'], color=color)
    N = 5
    df_grouped = df.groupby(['title', 'it_ot'])
    df_grouped_mean = df_grouped.median().unstack()
    df_grouped_mean_metric = df_grouped_mean[METRICS[0]]
    df_grouped_mean['metricDiff'] = (df_grouped_mean_metric['output/target'] - df_grouped_mean_metric['input/target'])
    df_grouped_mean.sort_values(by=['metricDiff'], ascending=[True], inplace=True)
    sorted_titles = df_grouped_mean.reset_index()['title'].iloc[:N].to_list()
    df = df_grouped.filter((lambda x: x['title'].isin(sorted_titles).all()))
    df_grouped = df.groupby(['title', 'it_ot'])
    it_colors = {title: np.asarray(plt.get_cmap('tab20')((((2 * idx) + 1) / 20))) for (idx, title) in enumerate(sorted_titles)}
    ot_colors = {title: np.asarray(plt.get_cmap('tab20')(((2 * idx) / 20))) for (idx, title) in enumerate(sorted_titles)}
    (fig, ax) = plt.subplots(1, len(METRICS), figsize=(10, 4))
    for (plot_idx, metric) in enumerate(METRICS):
        width = 0.6
        inner_space = ((width * 2) / 3)
        outer_space = 2
        df_grouped_metric = df_grouped[metric].apply(list)
        df_ot_grouped = df_grouped_metric.loc[:, 'output/target']
        df_it_grouped = df_grouped_metric.loc[:, 'input/target']
        for (idx, title) in enumerate(sorted_titles):
            it_value = df_it_grouped.loc[title]
            bp_it = ax[plot_idx].boxplot(it_value, positions=[((idx * outer_space) - inner_space)], sym=, widths=width)
            set_box_color(bp_it, it_colors[title])
            ot_value = df_ot_grouped.loc[title]
            bp_ot = ax[plot_idx].boxplot(ot_value, positions=[((idx * outer_space) + inner_space)], sym=, widths=width)
            set_box_color(bp_ot, ot_colors[title])
        ax[plot_idx].tick_params(axis='x', which='both', bottom=False, top=False, labelbottom=False)
        ax[plot_idx].set_title(METRICS_TITLE[plot_idx], fontdict=dict(fontsize=9))
        ax[plot_idx].set_ylabel('mm', labelpad=2.0)
    custom_legend_lines = [Line2D([0], [0], color=color, lw=4) for color in ot_colors.values()]
    fig.legend(custom_legend_lines, ot_colors.keys(), loc='upper right', ncol=((len(custom_legend_lines) // 4) + 1))
    plt.tight_layout()
    plt.subplots_adjust(wspace=0.3, top=0.75)