-
-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Expand file tree
/
Copy pathvoxels_simple.py
More file actions
31 lines (23 loc) · 672 Bytes
/
voxels_simple.py
File metadata and controls
31 lines (23 loc) · 672 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
"""
=========================
voxels([x, y, z], filled)
=========================
See `~mpl_toolkits.mplot3d.axes3d.Axes3D.voxels`.
"""
import matplotlib.pyplot as plt
import numpy as np
plt.style.use('_mpl-gallery')
# Prepare some coordinates
x, y, z = np.indices((8, 8, 8))
# Draw cuboids in the top left and bottom right corners
cube1 = (x < 3) & (y < 3) & (z < 3)
cube2 = (x >= 5) & (y >= 5) & (z >= 5)
# Combine the objects into a single boolean array
voxelarray = cube1 | cube2
# Plot
fig, ax = plt.subplots(subplot_kw={"projection": "3d"})
ax.voxels(voxelarray, edgecolor='k')
ax.set(xticklabels=[],
yticklabels=[],
zticklabels=[])
plt.show()