0
私は、リアルタイムで(x、y、z)で追加されたmatplotlib(python)を使用して3Dでプロットしたいと考えています。Matplotlibをz軸に追加
データはx軸とy軸に正常に追加されますが、z軸で問題が発生しました。matplotlibのドキュメントを検索しても、解決策は見つかりませんでした。
z軸にデータを追加するために、このコードに追加/変更するものを教えてください。
何が正しく動作:
return plt.plot(x, y, color='g')
問題:
return plt.plot(x, y, z, color='g')
コード:
from mpl_toolkits.mplot3d import axes3d
import matplotlib.pyplot as plt
import numpy as np
import matplotlib.animation as animation
import random
np.set_printoptions(threshold=np.inf)
fig = plt.figure()
ax1 = fig.add_subplot(111, projection='3d')
x = []
y = []
z = []
def animate(i):
x.append(random.randint(0,5))
y.append(random.randint(0,5))
z.append(random.randint(0,5))
return plt.plot(x, y, color='g')
#return plt.plot(x, y, z, color='g') => error
ani = animation.FuncAnimation(fig, animate, interval=1000)
ax1.set_xlabel('x')
ax1.set_ylabel('y')
ax1.set_zlabel('z')
plt.show()
これが正しく行わ取得する方法を?
ありがとう、awesome – shadow