いつもお世話になっております。
###前提・実現したいこと
プログラム(グラフ)を実行した状態のままCSVファイル(aiueo.csv)に値を追加(削除)した時に実行中のファイルに値を反映させる方法
アニメーションなども付加しているのでそれに影響がないように行いたい
###発生している問題・エラーメッセージ
やり方がわからない
###該当のソースコード
前回質問でアニメーションを付加したものです。
from
1import matplotlib.animation as animation 2from mpl_toolkits.mplot3d import Axes3D 3import numpy as np 4from scipy import genfromtxt 5 6# データ読み込み 7d = genfromtxt("aiueo.csv", delimiter=",") 8 9def animate(i, pl0,pl1,pl2): 10 pl0.set_data(d[:i,0], d[:i,1]) 11 pl0.set_3d_properties(d[:i,2]) 12 pl1.set_data(d[:i,0], d[:i,1]) 13 pl2.set_data(d[:i,2], d[:i,1]) 14 return pl0,pl1,pl1 15 16fig = pyplot.figure(figsize=(24,24)) 17 18# 3次元散布図 19ax = fig.add_subplot(121, projection='3d') 20ax.set_xlabel("X-axis") 21ax.set_ylabel("Y-axis") 22ax.set_zlabel("Z-axis") 23 24ax.set_xlim(-30, 30) 25ax.set_ylim(-40, 20) 26ax.set_zlim(100, 200) 27 28ax.plot(d[:,3], d[:,4], d[:,5], "o", color="g", ms=16, mew=0.5) 29pl0, = ax.plot([],[],[],"*", color="r", ms=16, mew=0.5) 30 31# 2次元グラフ1枚目 32ax = fig.add_subplot(222) 33ax.set_xlabel('x-axis') 34ax.set_ylabel('y-axis') 35ax.set_xlim(-30, 30) 36ax.set_ylim(-20, 20) 37 38ax.plot(d[:,3], d[:,4], "o", color="g", ms=24, mew=0.5) 39pl1, = ax.plot([], [], "*", color="r", ms=24, mew=0.5) 40ax.grid(True) 41 42# 2次元グラフ2枚目 43ax = fig.add_subplot(224) 44ax.set_xlabel('z-axis') 45ax.set_ylabel('y-axis') 46ax.set_xlim(100, 200) 47ax.set_ylim(-20,20) 48 49ax.plot(d[:,5], d[:,4], "o", color="g", ms=24, mew=0.5) 50pl2, = ax.plot([], [], "*", color="r", ms=24, mew=0.5) 51ax.grid(True) 52 53ani = animation.FuncAnimation(fig, animate, d.shape[0], fargs=(pl0,pl1,pl2), interval=0.25) 54 55pyplot.show()
###試したこと
対話モードなど検討してみたが行き詰ってしまった。
###補足情報(言語/FW/ツール等のバージョンなど)
windows10
python2.7
matplotlib
spyder
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。