我试图根据用户输入显示不同的数据集。 我正在尝试下面的示例代码:
import matplotlib.pyplot as plt
import numpy as np
N = int(raw_input())
X = []
Y = []
for i in range(N):
X.append(np.linspace(0,10,11))
Y.append( np.random.randn(11) )
def plotData(x, y):
fig = plt.figure()
plt.plot(x, y)
plt.show(block=False)
plotNumb = int(raw_input('Which plot should I display for you [integer from 0 to ' + str(N-1) + ']? '))
plotData(X[plotNumb],Y[plotNumb])
keepGoing = True
while keepGoing:
plotNumb = int(raw_input('Can I show you another one IN ADDITION [integer from 0 to ' + str(N-1) + ']? '))
plotData(X[plotNumb],Y[plotNumb])
keepGoing = raw_input("Do you want to keep going?")
if keepGoing == "Yes":
keepGoing = True
else:
keepGoing = False
问题是,数据没有显示,如图所示:
有没有办法在两个输入后都不调用show()
就可以让这个东西正常工作吗?我也不想跟踪用户已经关闭了哪些窗口。在
有人有什么好建议吗?在
编辑:就我在手册中所看到的,没有变通方法是无法做到这一点的。不过,也许有人知道解决办法。在
目前没有回答
相关问题 更多 >
编程相关推荐