プログラム初心者です。
Traceback (most recent call last):
File "test.py", line 42, in <module>
update()
TypeError: update() missing 5 required positional arguments: 'x', 'y', 'z', 'i', and 'plot'
のようなエラーが出ましたが,解決方法がわかりません。
python3
1import numpy as np 2import matplotlib.pyplot as plt 3from mpl_toolkits.mplot3d import Axes3D 4import matplotlib.animation as animation 5import sys 6 7fig = plt.figure() 8ax = fig.gca(projection='3d') 9 10#球の描画# 11 12u = np.linspace(0, 2 * np.pi, 100) 13v = np.linspace(0, np.pi, 100) 14x = 2 * np.outer(np.cos(u), np.sin(v)) 15y = 2 * np.outer(np.sin(u), np.sin(v)) 16z = 2 * np.outer(np.ones(np.size(u)), np.cos(v)) 17time=10 18 19def plot(): 20 ax.set_xlim(-10, 10) 21 ax.set_ylim(-10, 10) 22 ax.set_zlim(-10, 10) 23 ax.set_xlabel("x") 24 ax.set_ylabel("y") 25 ax.set_zlabel("z") 26 ax.set_aspect('equal') 27 plot=[ax.plot_surface(x, y, z)] 28 print(x) 29 30def update(x,y,z,i,plot): 31 print(x) 32 plot[0].remove() 33 i=0 34 for i in np.array(range(time)): 35 x_ = x 36 y_ = y 37 z_ = x * np.sin(i) + y * np.cos(i) 38 plot[0]=ax.plot_surface(x_, y_, z_, cmap="magma") 39 40 41if __name__ == '__main__': 42 # init() 43 plot() 44 update() 45 ani = animation.FuncAnimation(fig, update, 100, fargs=(x,y,z,i,plot), interval=100) 46 plt.show() 47 48
コードは以下のように記載しました。
どう直したら解決できるのでしょうか?
コードはご自身で書いたものでしょうか?参考にしたページなどがあれば記載ください。
こちらのページを参考に作成しました。
<https://sabopy.com/py/matplotlib_animation_3/>
回答1件
あなたの回答
tips
プレビュー