forked from tdamdouni/Pythonista
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path3dcube.py
62 lines (55 loc) · 1.56 KB
/
3dcube.py
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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
# http://matplotlib.1069221.n5.nabble.com/attachment/4748/1/3dcube.py
from mpl_toolkits.mplot3d import Axes3D
import matplotlib.pyplot as plt
import numpy as np
fig=plt.figure()
ax = Axes3D(fig)
# Face 1
x1 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
y1 = np.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])
z1 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
# Face 2
x2 = np.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])
y2 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
z2 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
# Face 3
x3 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
y3 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
z3 = np.array([[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]])
# Face 4
x4 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
y4 = np.array([[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]])
z4 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
# Face 5
x5 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
y5 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
z5 = np.array([[0, 0, 0, 0, 0],
[0, 0, 0, 0, 0]])
# Face 6
x6 = np.array([[1, 1, 1, 1, 1],
[1, 1, 1, 1, 1]])
y6 = np.array([[0, 1, 1, 0, 0],
[0, 0, 0, 0, 0]])
z6 = np.array([[0, 0, 1, 1, 0],
[0, 0, 0, 0, 0]])
ax.plot_surface(x1,y1,z1)
ax.plot_surface(x2,y2,z2)
ax.plot_surface(x3,y3,z3)
ax.plot_surface(x4,y4,z4)
ax.plot_surface(x5,y5,z5)
ax.plot_surface(x6,y6,z6)
plt.show()