質問編集履歴
3
細かいところを訂正しました
test
CHANGED
File without changes
|
test
CHANGED
@@ -270,7 +270,7 @@
|
|
270
270
|
|
271
271
|
|
272
272
|
|
273
|
-
|
273
|
+
※lines=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data]※
|
274
274
|
|
275
275
|
points=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o')[0] for dat in data]
|
276
276
|
|
@@ -286,7 +286,7 @@
|
|
286
286
|
|
287
287
|
|
288
288
|
|
289
|
-
|
289
|
+
※この印が訂正点です※
|
290
290
|
|
291
291
|
|
292
292
|
|
2
初心者アイコンをつけました。
test
CHANGED
File without changes
|
test
CHANGED
File without changes
|
1
追記
test
CHANGED
File without changes
|
test
CHANGED
@@ -171,3 +171,263 @@
|
|
171
171
|
|
172
172
|
|
173
173
|
よろしくお願いします。
|
174
|
+
|
175
|
+
|
176
|
+
|
177
|
+
|
178
|
+
|
179
|
+
2019年6月29日追記
|
180
|
+
|
181
|
+
|
182
|
+
|
183
|
+
```ここに言語を入力
|
184
|
+
|
185
|
+
%matplotlib notebook
|
186
|
+
|
187
|
+
%matplotlib nbagg
|
188
|
+
|
189
|
+
from mpl_toolkits.mplot3d import Axes3D
|
190
|
+
|
191
|
+
import matplotlib.pyplot as plt
|
192
|
+
|
193
|
+
import matplotlib.animation as animation
|
194
|
+
|
195
|
+
from IPython.display import HTML
|
196
|
+
|
197
|
+
import numpy as np
|
198
|
+
|
199
|
+
|
200
|
+
|
201
|
+
def init():
|
202
|
+
|
203
|
+
ax.set_xlim(-10,10)
|
204
|
+
|
205
|
+
ax.set_ylim(-10,10)
|
206
|
+
|
207
|
+
ax.set_zlim(0,10)
|
208
|
+
|
209
|
+
ax.set_xlabel("x")
|
210
|
+
|
211
|
+
ax.set_ylabel("y")
|
212
|
+
|
213
|
+
ax.set_zlabel("z")
|
214
|
+
|
215
|
+
ax.set_aspect('equal')
|
216
|
+
|
217
|
+
|
218
|
+
|
219
|
+
return lines
|
220
|
+
|
221
|
+
|
222
|
+
|
223
|
+
x1,y1,z1 = [],[],[]
|
224
|
+
|
225
|
+
|
226
|
+
|
227
|
+
x1=[1,8,3,6,3,6,4]
|
228
|
+
|
229
|
+
y1=[9,1,5,3,7,3,8]
|
230
|
+
|
231
|
+
z1=[0,2,5,7,1,0,5]
|
232
|
+
|
233
|
+
|
234
|
+
|
235
|
+
|
236
|
+
|
237
|
+
def update_lines(num, data, lines,points):
|
238
|
+
|
239
|
+
for dat,line, point in zip(data,lines, points):
|
240
|
+
|
241
|
+
point.set_data(dat[0:2, num])
|
242
|
+
|
243
|
+
point.set_3d_properties(dat[2, num])
|
244
|
+
|
245
|
+
|
246
|
+
|
247
|
+
return lines
|
248
|
+
|
249
|
+
|
250
|
+
|
251
|
+
# Attaching 3D axis to the figure
|
252
|
+
|
253
|
+
fig = plt.figure()
|
254
|
+
|
255
|
+
ax = fig.gca(projection='3d')
|
256
|
+
|
257
|
+
|
258
|
+
|
259
|
+
# Lines to plot in 3D
|
260
|
+
|
261
|
+
t = np.linspace(-3, 2, 30)
|
262
|
+
|
263
|
+
z = np.linspace(-3, 2, 30)
|
264
|
+
|
265
|
+
r = np.linspace(-3, 2, 30)
|
266
|
+
|
267
|
+
x1, y1, z1 = x1, y1, z1#プロットするデータ
|
268
|
+
|
269
|
+
data = np.array([[x1,y1,z1]])#プロットするデータ
|
270
|
+
|
271
|
+
|
272
|
+
|
273
|
+
**lines=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data]**
|
274
|
+
|
275
|
+
points=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o')[0] for dat in data]
|
276
|
+
|
277
|
+
|
278
|
+
|
279
|
+
line_ani = animation.FuncAnimation(fig, update_lines, 300, fargs=(data, lines,points),
|
280
|
+
|
281
|
+
interval=10, init_func=init, blit=True, repeat=True)
|
282
|
+
|
283
|
+
|
284
|
+
|
285
|
+
```
|
286
|
+
|
287
|
+
|
288
|
+
|
289
|
+
**この印が訂正点です**
|
290
|
+
|
291
|
+
|
292
|
+
|
293
|
+
以上のコードで動かないという問題点は解決いたしました。
|
294
|
+
|
295
|
+
しかし、複数のコードを動かすために以下のようなコードを組んだのですが
|
296
|
+
|
297
|
+
x2,y2,z2,の座標の点しか現れませんでした。
|
298
|
+
|
299
|
+
解決策の知恵をお貸し願いたいです。
|
300
|
+
|
301
|
+
|
302
|
+
|
303
|
+
```ここに言語を入力
|
304
|
+
|
305
|
+
%matplotlib notebook
|
306
|
+
|
307
|
+
%matplotlib nbagg
|
308
|
+
|
309
|
+
from mpl_toolkits.mplot3d import Axes3D
|
310
|
+
|
311
|
+
import matplotlib.pyplot as plt
|
312
|
+
|
313
|
+
import matplotlib.animation as animation
|
314
|
+
|
315
|
+
from IPython.display import HTML
|
316
|
+
|
317
|
+
import numpy as np
|
318
|
+
|
319
|
+
|
320
|
+
|
321
|
+
def init():
|
322
|
+
|
323
|
+
ax.set_xlim(-10,10)
|
324
|
+
|
325
|
+
ax.set_ylim(-10,10)
|
326
|
+
|
327
|
+
ax.set_zlim(0,10)
|
328
|
+
|
329
|
+
ax.set_xlabel("x")
|
330
|
+
|
331
|
+
ax.set_ylabel("y")
|
332
|
+
|
333
|
+
ax.set_zlabel("z")
|
334
|
+
|
335
|
+
ax.set_aspect('equal')
|
336
|
+
|
337
|
+
|
338
|
+
|
339
|
+
return lines
|
340
|
+
|
341
|
+
|
342
|
+
|
343
|
+
|
344
|
+
|
345
|
+
|
346
|
+
|
347
|
+
x1,y1,z1 = [],[],[]
|
348
|
+
|
349
|
+
x2,y2,z2 = [],[],[]
|
350
|
+
|
351
|
+
|
352
|
+
|
353
|
+
x1=[1,8,3,6,3,6,4]
|
354
|
+
|
355
|
+
y1=[9,1,5,3,7,3,8]
|
356
|
+
|
357
|
+
z1=[0,2,5,7,1,0,5]
|
358
|
+
|
359
|
+
|
360
|
+
|
361
|
+
x2=[-1,-8,3-,-6,-3,-6,-4]
|
362
|
+
|
363
|
+
y2=[-9,-1,-5,-3,-7,-3,-8]
|
364
|
+
|
365
|
+
z2=[1,3,1,2,4,2,4]
|
366
|
+
|
367
|
+
|
368
|
+
|
369
|
+
|
370
|
+
|
371
|
+
def update_lines(num, data, lines,points):
|
372
|
+
|
373
|
+
for dat,line, point in zip(data,lines, points):
|
374
|
+
|
375
|
+
point.set_data(dat[0:2, num+1])
|
376
|
+
|
377
|
+
point.set_3d_properties(dat[2, num+1])
|
378
|
+
|
379
|
+
|
380
|
+
|
381
|
+
return lines
|
382
|
+
|
383
|
+
|
384
|
+
|
385
|
+
|
386
|
+
|
387
|
+
# Attaching 3D axis to the figure
|
388
|
+
|
389
|
+
fig = plt.figure()
|
390
|
+
|
391
|
+
ax = fig.gca(projection='3d')
|
392
|
+
|
393
|
+
|
394
|
+
|
395
|
+
# Lines to plot in 3D
|
396
|
+
|
397
|
+
t = np.linspace(-3, 2, 30)
|
398
|
+
|
399
|
+
z = np.linspace(-3, 2, 30)
|
400
|
+
|
401
|
+
r = np.linspace(-3, 2, 30)
|
402
|
+
|
403
|
+
x1, y1, z1 = x1, y1, z1#プロットするデータ
|
404
|
+
|
405
|
+
data = np.array([[x1,y1,z1]])#プロットするデータ
|
406
|
+
|
407
|
+
x2, y2, z2 = x2, y2, z2#プロットするデータ
|
408
|
+
|
409
|
+
data = np.array([[x2,y2,z2]])#プロットするデータ
|
410
|
+
|
411
|
+
|
412
|
+
|
413
|
+
|
414
|
+
|
415
|
+
lines=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1] )[0] for dat in data]
|
416
|
+
|
417
|
+
points=[ax.plot(dat[0, 0:1], dat[1, 0:1], dat[2, 0:1], 'o')[0] for dat in data]
|
418
|
+
|
419
|
+
|
420
|
+
|
421
|
+
line_ani = animation.FuncAnimation(fig, update_lines, 300, fargs=(data,lines, points),
|
422
|
+
|
423
|
+
interval=10, init_func=init, blit=True, repeat=True)
|
424
|
+
|
425
|
+
|
426
|
+
|
427
|
+
|
428
|
+
|
429
|
+
```
|
430
|
+
|
431
|
+
|
432
|
+
|
433
|
+
よろしくお願いいたします。
|