Skip to content

Commit

Permalink
close figures once they are used
Browse files Browse the repository at this point in the history
  • Loading branch information
dodu94 committed Feb 24, 2025
1 parent f751914 commit 18a4b1d
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions src/jade/post/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 18a4b1d

Please sign in to comment.