如何在没有逐个关闭matplotlib中的第一个数字的情况下获得许多数字。我的代码如下:
import matplotlib.pyplot as plt
x = [1,2,3,4,5,6,7,8,9,10]
y = [1,4,9,16,25,36,49,64,81,100]
z=[1,3,4,5,19,13,17,12,15,10]
v=[1,2,4,5,7,8,90,3,2,2]
def func(x,y):
plt.plot(x, y)# I want the first graph to stay and get second one without closing first
plt.show()
return
func(x,y)
myinput=int(input())
if myinput==1:
func(x,z)
else:
func(x,v)
#something like this i want
#answering myself after spending lot of time
x = [1,2,3,4,5,6,7,8,9,10]
y = [1,4,9,16,25,36,49,64,81,100]
z=[1,3,4,5,19,13,17,12,15,10]
v=[1,2,4,5,7,8,90,3,2,2]
def func(x,y,index):
fig=plt.figure(index)
fig1=fig.add_subplot(1,1,1)
fig1.plot(x, y)
plt.show(block=False)
return
my_input=1
while(my_input!=-1):
my_input=int(input())
func(x,y,my_input)