0

When I run a Python script which creates and saves a matplotlib figure, the figure is shown in a new PyCharm window (even if there is no plt.show() in my code). If I have many figures created in the script, then many windows are opened. This tends to be very buggy and I'd like to know if there is a way to prevent the opening of those windows.

EDIT: This happens when I run with Python Console. See the screenshot below. enter image description here

EDIT 2: If I plt.close() the figures in the script, the windows open furtively then automatically close. This is better but it is still annoying to get all these windows that pop up.

TVG
  • 370
  • 2
  • 11
  • 1
    Could you provide a minimum code example? – Gonzalo Odiard Apr 20 '22 at 00:34
  • I have edited my post to show a simple example. – TVG Apr 20 '22 at 14:27
  • Did you read https://stackoverflow.com/questions/9622163/save-plot-to-image-file-instead-of-displaying-it-using-matplotlib ,https://stackoverflow.com/questions/29125228/python-matplotlib-save-graph-without-showing and https://stackoverflow.com/questions/61985515/how-to-save-images-using-matplotlib-without-displaying-them ? – Gonzalo Odiard Apr 20 '22 at 17:03
  • Thanks. I found that I can close the windows with `plt.close()`. Then, a new window that is created with `plt.figure()` is automatically closed. – TVG Apr 21 '22 at 07:13

0 Answers0