1#where to save the figures
2PROJECT_ROOT_DIR = "."
3CHAPTER_ID = "classification"
4IMAGES_PATH = os.path.join(PROJECT_ROOT_DIR, "images", CHAPTER_ID)
5os.makedirs(IMAGES_PATH, exist_ok = True)
6
7def save_fig(fig_id, tight_layout=True, fig_extension="png", resolution=300):
8 path = os.path.join(IMAGES_PATH, fig_id + "." + fig_extension)
9 print("Saving figure", fig_id)
10 if tight_layout:
11 plt.tight_layout()
12 plt.savefig(path, format=fig_extension, dpi=resolution)