From 18a4b1d380ab030d309aef5bae934eeb4f360886 Mon Sep 17 00:00:00 2001 From: DAVIDE LAGHI Date: Mon, 24 Feb 2025 22:56:49 +0100 Subject: [PATCH] close figures once they are used --- src/jade/post/atlas.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/jade/post/atlas.py b/src/jade/post/atlas.py index 773d9535..0e169077 100644 --- a/src/jade/post/atlas.py +++ b/src/jade/post/atlas.py @@ -5,13 +5,15 @@ # import win32com.client # import aspose.words import docx -import pandas as pd -from docx.enum.table import WD_ALIGN_VERTICAL + +# from docx.enum.table import WD_ALIGN_VERTICAL from docx.enum.text import WD_ALIGN_PARAGRAPH -from docx.oxml import OxmlElement, parse_xml -from docx.oxml.ns import nsdecls, qn + +# from docx.oxml import OxmlElement, parse_xml +# from docx.oxml.ns import nsdecls, qn from docx.shared import Inches from matplotlib.figure import Figure +import matplotlib.pyplot as plt from jade.helper.aux_functions import PathLike @@ -66,6 +68,8 @@ def insert_img(self, figure: Figure, width=Inches(7.5)): img_stream.seek(0) self.doc.add_picture(img_stream, width=width) + # be sure to close the figure once it has been added + plt.close(figure) last_paragraph = self.doc.paragraphs[-1] last_paragraph.alignment = WD_ALIGN_PARAGRAPH.CENTER