Figure()-Pyplot中的函数抛出ValueError

时间:2018-09-17 08:41:34

标签: python matplotlib

我正在尝试使用python和matplotlib绘制一些数据。 为了在地块上进行更新,我将使用set_ydata()函数。

我正在使用here

中的示例代码
import matplotlib.pyplot as plt
import numpy as np

x = np.linspace(0, 10*np.pi, 100)
y = np.sin(x)

plt.ion()
fig = plt.figure()
ax = fig.add_subplot(111)
line1, = ax.plot(x, y, 'b-') 

for phase in np.linspace(0, 10*np.pi, 100):
    line1.set_ydata(np.sin(0.5 * x + phase))
    fig.canvas.draw()

运行程序时出现错误

ValueError: max() arg is an empty sequence

逐步完成Programm之后,我发现调用函数plt.figure()时会发生此错误。 这是怎么回事

谢谢!

0 个答案:

没有答案
相关问题