Skip to content

Commit

Permalink
adjusted fontsize
Browse files Browse the repository at this point in the history
  • Loading branch information
Steffen committed Feb 18, 2021
1 parent 5721c56 commit 454bff4
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 10 deletions.
25 changes: 18 additions & 7 deletions src/plots/hparam_tuning.py
Original file line number Diff line number Diff line change
Expand Up @@ -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():
Expand All @@ -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'))

Expand Down
14 changes: 11 additions & 3 deletions src/plots/test_score.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -48,15 +50,21 @@
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):
patch.set_facecolor(color)

# 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
Expand Down

0 comments on commit 454bff4

Please sign in to comment.