-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathplot.py
More file actions
36 lines (27 loc) · 863 Bytes
/
plot.py
File metadata and controls
36 lines (27 loc) · 863 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import matplotlib.pyplot as plt
from mpl_toolkits.mplot3d import Axes3D
import numpy as np
def plot_cube3d(coords):
fig = plt.figure()
ax = fig.add_subplot(111, projection='3d')
ax.scatter(coords[:, 0], coords[:, 1], coords[:, 2], zdir='z', c='red')
plt.axis('equal')
plt.show()
def plot_cube2d(cubes):
plt.plot(cubes[:, 0], cubes[:, 2], 'ro')
plt.axis('equal')
plt.show()
def reduce_coords(coords):
c = []
for i, coord in enumerate(coords):
coord[1] = -coord[1]
x, y, z = coord
if not np.math.isnan(x) and y < 0.5 and z < 1.5 and 0 < x < 0.25:
if i % 10 != 0:
continue
c.append(coord)
return np.asarray(c)
if __name__ == '__main__':
coords = np.loadtxt('coords_8.txt', dtype=float)
coords = reduce_coords(coords)
plot_cube3d(coords)