粒子の移動を2次元的にプロットするサンプル
| import numpy as np |
| import matplotlib.pyplot as plt |
| import csv |
| import pprint |
| |
| file_pairs = [('./csv-000060.csv','./csv-008460.csv'), |
| ('./csv-000060.csv','./csv-008460.csv'), |
| ('./csv-000060.csv','./csv-008460.csv'), |
| ('./csv-000060.csv','./csv-008460.csv')] |
| |
| titles = ['Case-A','Case-B','Case-C','Case-D'] |
| |
| figure, axes = plt.subplots(2,2, figsize=(5,5)) |
| |
| for n, file_pair in enumerate(file_pairs): |
| px, py = [],[] |
| for file in file_pair: |
| with open(file) as f: |
| reader = csv.reader(f) |
| next(reader) |
| x,y = np.array([list(map(float, row)) for row in reader]).transpose()[6:8] |
| px.append(x) |
| py.append(y) |
| |
| |
| draw_circle = plt.Circle((7100, 6100), 6000,fill="gray", alpha=0.1, edgecolor="k") |
| axe = axes[int(np.floor(n/2)),n%2] |
| axe.set_title(titles[n],y=0.92) |
| axe.set_xlim(0,14000) |
| axe.set_ylim(0,13000) |
| axe.set_aspect(1) |
| axe.add_artist(draw_circle) |
| axe.axis('off') |
| |
| axe.scatter(px[0],py[0],c="k", alpha=0.8, s=5) |
| axe.scatter(px[1],py[1],c="0.5", alpha=0.8, s=5) |
| plt.tight_layout() |
| plt.savefig('particle_movement.png') |
| plt.show() |