'plt.show() does nothing when used for the second time

I am just starting to learn data science using python on Data Camp and I noticed something while using the functions in matplotlib.pyplot

import matplotlib.pyplot as plt

year = [1500, 1600, 1700, 1800, 1900, 2000]
pop = [458, 580, 682, 1000, 1650, 6,127]

plt.plot(year, pop)

plt.show() # Here a window opens up and shows the figure for the first time

but when I try to show it again it doesn't..

plt.show() # for the second time.. nothing happens

And I have to retype the line above the show() to be able to show a figure again

Is this the normal thing or a problem?

Note: I am using the REPL



Solution 1:[1]

Using command:

%matplotlib

in ipython3 help me to use separate window with plot

Solution 2:[2]

Start ipython3 and issue the commands:

import matplotlib.pyplot as plt
%matplotlib #plot in separate window
fig, ax = plt.subplots() #Appear empty Tcl window for image
ax.plot([1, 2, 3, 4], [5, 6, 7, 8]) #Appear graph in window

enter image description here

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 Erzi
Solution 2 Erzi