因为我前端读取数据花费的时间比较长,我需要在数据读取完毕之后作图,所以选择了while 循环来完成这件事情。但是在while循环中,并不能做出图来,现在我把问题找到,并简化成下面的样子,哪位能帮我分析分析具体,该如何修改。
import numpy as np
import matplotlib.pyplot as plt
x=np.linspace(0,2*pi,20)
y=np.sin(x)
z=np.cos(x)
while 1:
nPlt = input('input nPlt:')
if nPlt == 1:
plt.plot(x,y)
elif nPlt == 2:
plt.plot(x,z)
else:
break