'How to prevent the opening of new windows with figures?

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.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source