質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.48%
Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

Q&A

0回答

2600閲覧

3D アニメーション 点と点を直線で繋げたい

rr9500sc

総合スコア16

Jupyter

Jupyter (旧IPython notebook)は、Notebook形式でドキュメント作成し、プログラムの記述・実行、その実行結果を記録するツールです。メモの作成や保存、共有、確認などもブラウザ上で行うことができます。

Python

Pythonは、コードの読みやすさが特徴的なプログラミング言語の1つです。 強い型付け、動的型付けに対応しており、後方互換性がないバージョン2系とバージョン3系が使用されています。 商用製品の開発にも無料で使用でき、OSだけでなく仮想環境にも対応。Unicodeによる文字列操作をサポートしているため、日本語処理も標準で可能です。

0グッド

0クリップ

投稿2019/07/08 09:43

こんにちは。
現在jupyter notebookにて
下記のような3次元座標空間の中で3つの点が動くプログラムを組んでいるのですが
point1とpoint2
point2とpoint3を繋ぐ線を引きたいと考えております。

%matplotlib notebook %matplotlib nbagg import mpl_toolkits.mplot3d as plt3d from mpl_toolkits.mplot3d import Axes3D import matplotlib.pyplot as plt import matplotlib.animation as animation from IPython.display import HTML import numpy as np def init(): ax.set_xlim(-10,10) ax.set_ylim(-10,10) ax.set_zlim(-10,10) ax.set_xlabel("x") ax.set_ylabel("y") ax.set_zlabel("z") ax.set_aspect('equal') return lines1,lines2,lines3 x1,y1,z1 = [],[],[] x2,y2,z2 = [],[],[] x3,y3,z3 = [],[],[] x1=[1,8,3,6,3,6,4] y1=[9,1,5,3,7,3,8] z1=[0,2,5,7,1,0,5] x2=[-1,-8,-3,-6,-3,-6,-4] y2=[-9,-1,-5,-3,-7,-3,-8] z2=[1,3,1,2,4,2,4] x3=[6,8,3,0,7,1,2] y3=[1,5,6,4,7,0,8] z3=[2,2,4,4,0,0,7] def update_lines(num,data1,data2,data3,lines1,lines2,lines3,points1,points2, points3): for dat1,dat2,dat3,line1,line2,line3,point1,point2, point3 in zip(data1,data2,data3,lines1,lines2,lines3,points1,points2, points3): point1.set_data(dat1[0:2, num+1]) point1.set_3d_properties(dat1[2, num+10]) point2.set_data(dat2[0:2, num+1]) point2.set_3d_properties(dat2[2, num+10]) point3.set_data(dat3[0:2, num+1]) point3.set_3d_properties(dat3[2, num+10]) return lines1,lines2,lines3, fig = plt.figure() ax = fig.gca(projection='3d') t = np.linspace(-3, 2, 30) z = np.linspace(-3, 2, 30) r = np.linspace(-3, 2, 30) x1, y1, z1 = x1, y1, z1 x2, y2, z2 = x2, y2, z2 x3, y3, z3 = x3, y3, z3 data1 = np.array([[x1,y1,z1]]) data2 = np.array([[x2,y2,z2]]) data3 = np.array([[x3,y3,z3]]) lines1=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data1] lines2=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data2] lines3=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data3] points1=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o-')[0] for dat in data1] points2=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o-')[0] for dat in data2] points3=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o-')[0] for dat in data3] line_ani = animation.FuncAnimation(fig, update_lines, 172, fargs=(data1,data2,data3,lines1,lines2,lines3, points1,points2,points3), interval=10, init_func=init, blit=True, repeat=True,)

pointの部分に'o-'を入力することで
丸い点に線結びのようなプログラムになると思っていたのですが
丸い点が動くだけのプログラムになってしまい、直線が現れませんでした。

動く点と点を直線で結ぶ方法をご存知の方がいらっしゃれば
お力添え願いたいです。
よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

まだ回答がついていません

会員登録して回答してみよう

アカウントをお持ちの方は

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.48%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問