前提・実現したいこと
jupiter notebookにて下記のようなプログラムを組んでいて
1つのプロットを動かせるようになったが複数のプロットを同時に動かせるようにしたい。
また、現在はプロットの軌道が残るようになっているが
それを消し、軌道を残さずプロットが動いているようにしたい。
発生している問題・エラーメッセージ
実現が出来ていないこと。
該当のソースコード
%matplotlib nbagg from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.animation as animation with open('example.txt','r') as f: graph_data = f.read() xs=[] ys=[] zs=[] for line in graph_data.splitlines(): if line: x,y,z = line.split(',') xs.append(float(x)) ys.append(float(y)) zs.append(float(z)) def animate(i, line): line.set_data(xs[:i],ys[:i]) line.set_3d_properties(zs[:i]) return line fig=plt.figure() ax = Axes3D(fig) ax.cla() ln, = ax.plot([],[],[],"o", ms=4, mew=0.5) ax.grid(True, linestyle = '-', color = '0.75') ax.set_xlim(0,10) ax.set_ylim(0,10) ax.set_zlim(0,10) ani = animation.FuncAnimation(fig, animate, len(xs)+1, fargs=(ln,), interval=100) plt.show()
試したこと
with open('example.txt','r') as f:
graph_data = f.read()
xs=[]
ys=[]
zs=[]
for line in graph_data.splitlines():
if line:
x,y,z = line.split(',')
xs.append(float(x))
ys.append(float(y))
zs.append(float(z))
を増やす等。
補足情報(FW/ツールのバージョンなど)
example.txtには
1, 1, 1
2, 2, 2
3, 3, 3
4, 4, 4
5, 5, 5
6, 6, 6
7, 7, 7
と記入しています。
あなたの回答
tips
プレビュー