From 454bff4a1bf20d4526a4f21b97c02f8ab919a71d Mon Sep 17 00:00:00 2001 From: Steffen Date: Thu, 18 Feb 2021 11:41:19 +0100 Subject: [PATCH] adjusted fontsize --- src/plots/hparam_tuning.py | 25 ++++++++++++++++++------- src/plots/test_score.py | 14 +++++++++++--- 2 files changed, 29 insertions(+), 10 deletions(-) diff --git a/src/plots/hparam_tuning.py b/src/plots/hparam_tuning.py index 7dbb5d8..4395460 100644 --- a/src/plots/hparam_tuning.py +++ b/src/plots/hparam_tuning.py @@ -55,7 +55,7 @@ def plot(hparam_tuning_results): # set up sup-plots fig = plt.figure(figsize=(8.5, 2.5)) axs = fig.subplots(1, len(DATASET_ORDER)) - plt.subplots_adjust(bottom=0.15) + plt.subplots_adjust(bottom=0.18) for i, dataset in enumerate(DATASET_ORDER): if dataset not in hparam_tuning_results.keys(): @@ -67,16 +67,27 @@ def plot(hparam_tuning_results): items = hparam_tuning_results[dataset][lossfun].items() items = sorted(items,key=lambda t: t[0]) lambdas, val_dice_overlap = list(zip(*items)) - axs[i].plot(lambdas, val_dice_overlap, color=LOSS_FUNTION_CONFIG[lossfun]["primary_color"], label=LOSS_FUNTION_CONFIG[lossfun]["display_name"]) + line = axs[i].plot(lambdas, val_dice_overlap, color=LOSS_FUNTION_CONFIG[lossfun]["primary_color"], label=LOSS_FUNTION_CONFIG[lossfun]["display_name"]) axs[i].scatter(lambdas, val_dice_overlap, color=LOSS_FUNTION_CONFIG[lossfun]["primary_color"], marker='x') axs[i].set_xscale('log', basex=2) - axs[i].set_title(PLOT_CONFIG[dataset]["display_name"]) + axs[i].set_title(PLOT_CONFIG[dataset]["display_name"], fontsize=18) + LOSS_FUNTION_CONFIG[lossfun]["handle"] = line[0] # add labels - fig.text(0.5, 0.015, "Regularization Hyperparameter $\lambda$", ha="center", va="center") - fig.text(0.07, 0.5, "Validation Mean Dice Overlap", ha="center", va="center", rotation="vertical") - #axs[-1].legend() - # configure precision + fig.text(0.5, 0.03, "Regularization Hyperparameter $\lambda$", ha="center", va="center", fontsize=16) + fig.text(0.07, 0.5, "Val. Mean Dice Overlap", ha="center", va="center", rotation="vertical", fontsize=16) + + # add legend + # handles = [ + # LOSS_FUNTION_CONFIG[loss_function]["handle"] for loss_function in LOSS_FUNTION_ORDER + # ] + # labels = [ + # LOSS_FUNTION_CONFIG[loss_function]["display_name"] + # for loss_function in LOSS_FUNTION_ORDER + # ] + # axs[-1].legend(handles, labels, loc="upper left", fontsize="x-small") + + # configure axis precision for ax in axs: ax.yaxis.set_major_formatter(FormatStrFormatter('%.2f')) diff --git a/src/plots/test_score.py b/src/plots/test_score.py index 1296f6c..48c8626 100644 --- a/src/plots/test_score.py +++ b/src/plots/test_score.py @@ -6,13 +6,15 @@ import torch from .config import * from .run_models import run_models +from matplotlib.ticker import FormatStrFormatter # set up sup-plots -fig = plt.figure(figsize=(8, 3)) +fig = plt.figure(figsize=(7, 2.5)) axs = fig.subplots(1, len(DATASET_ORDER)) -plt.subplots_adjust(bottom=0.3) +plt.subplots_adjust(bottom=0.32, wspace=0.3) plt.rcParams["boxplot.medianprops.color"] = "k" plt.rcParams["boxplot.medianprops.linewidth"] = 3.0 +outlier_porps = dict(markersize=3, markeredgecolor="black", marker='.') results = run_models(use_cached=True) for i, dataset in enumerate(DATASET_ORDER): # set dataset title @@ -48,6 +50,7 @@ vert=True, # vertical box alignment patch_artist=True, # fill with color labels=labels, + flierprops=outlier_porps ) # will be used to label x-ticks # color boxes for patch, color in zip(bplot["boxes"], colors): @@ -55,8 +58,13 @@ # rotate labels for tick, color in zip(axs[i].get_xticklabels(), label_colors): - tick.set_rotation(70) + tick.set_rotation(60) tick.set_color(color) + + +# configure axis precision +for ax in axs: + ax.yaxis.set_major_formatter(FormatStrFormatter('%.2f')) # add labels