def save_plot(is_save, save_path): if is_save: pdf = PdfPages(save_path) pdf.savefig(bbox_inches='tight') pdf.close()