'new plot window plot every time I run my script

I'm running a simple script in ipython, and no problem to get the plot and update the figure every time I run it

plt.clf()    
plt.plot(x,y,'bo')
plt.show()

However, if I try to plot multiple panels

fig, axs = plt.subplots(1,3)
axs[0].plot(x,y,'bo')
axs[1].plot(x,z,'bo')
axs[2].plot(y,z,'bo')
plt.show()

a new window with the three panels is created every time I run my scrip (unless I exit and restart the ipython session). What shall I do? Thanks!



Solution 1:[1]

subplots creates a new figure by default, but you can also specify which figure to plot into, if you do so then it will only open that one figure / window:

fig, axs = plt.subplots(1,3, num=1) # force to plot into figure 1

Sources

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

Source: Stack Overflow

Solution Source
Solution 1 Julien