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)
1import matplotlib.pyplot as plt
2plt.figure()
3plt.plot([1,2,3],[1,2,3])
4plt.savefig("out.png")
1I can't get this to work. Do I need to modify the paths or anything? ALso, when I try to run the save_fig, it needs the fig_id. I don't knoww what this is.