いつもお世話になっております。
###発生している問題・エラーメッセージ
with open("aiueo.csv", "rb") as f:
読み込もうとしているファイルを
ax.plot(f[:,10], f[:,9], "x", color="r", ms=24, mew=0.5)
という風に実行しようと試みたが、
TypeError: 'file' object has no attribute '__getitem__'
というエラーメッセージが出てきてしまい実行することが出来なかった。
"aiueo.csv"に関してはOpenCVで動画分析を行ってその座標がプログラムで打ち込まれるようになっています。
追記
Python
1d = genfromtxt("example.csv", delimiter=",") # データ読み込み 計画線量 2"tail -f aiueo.csv | python this program.py" 3with open('aiueo.csv', 'rb') as f: 4 rows = csv.reader(sys.stdin) 5 next(rows) # ヘッダを捨てる 6 for row in rows: 7 print float(row[0]) # 最初のカラムを数値として表示 8 9fig = pyplot.figure(figsize=(16,9)) 10 11 12# 全体を2x2に分割し、1枚目(左半分)に描写 13ax = fig.add_subplot(121, projection='3d') 14ax.set_xlabel("X-axis") 15ax.set_ylabel("Y-axis") 16ax.set_zlabel("Z-axis") 17ax.set_xlim(-30, 30) 18ax.set_ylim(-40, 20) 19ax.set_zlim(100, 200) 20 21ax.plot(d[:,0], d[:,1], d[:,2], "o", color="g", ms=16, mew=0.5) 22ax.plot(row[:,8], row[:,9], row[:,10], "x", color="r", ms=16, mew=0.5) 23 24ax.grid(True) 25 26# 全体を2x2に分割し、2枚目(右上)に描写 27ax = fig.add_subplot(222) 28ax.set_xlabel('X-axis') 29ax.set_ylabel('Y-axis') 30ax.set_xlim(-30, 30) 31ax.set_ylim(-40, 20) 32 33ax.plot(d[:,0], d[:,1], "o", color="g", ms=24, mew=0.5) 34ax.plot(row[:,8], row[:,9], "x", color="r", ms=24, mew=0.5) 35ax.grid(True) 36 37 38# 全体を2x2に分割し、3枚目(右下) に描写 39ax = fig.add_subplot(224) 40ax.set_xlabel('Z-axis') 41ax.set_ylabel('Y-axis') 42ax.set_xlim(100, 200) 43ax.set_ylim(-40,20) 44 45ax.plot(d[:,2], d[:,1], "o", color="g", ms=24, mew=0.5) 46ax.plot(row[:,10], row[:,9], "x", color="r", ms=24, mew=0.5) 47 48 49ax.grid(True) 50 51 52f.close() 53cv2.destroyAllWindows() 54src.release() 55rec.release() 56fig.show() 57pyplot.pause(0.1)
pyplot.pause(interval)にしたら上手くいくかも?みたいな記事を読んでみたのですがそれでも失敗しました。
###補足情報(言語/FW/ツール等のバージョンなど)
windows10
python2.7
matplotlib
spyder
OpenCV
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2017/06/26 05:32
2017/06/26 05:38
2017/06/27 13:38
2017/06/27 14:20
2017/07/02 06:06
2017/07/02 11:12
2017/07/02 15:49
2017/07/02 16:06
2017/07/03 03:03
2017/07/03 03:07
2017/07/03 03:21
2017/07/03 03:51
2017/07/03 05:44
2017/07/03 05:57
2017/07/03 06:00