3D Voxels
Cubic Wireframe Voxels
Hollow cube showing only edges with neon pink coloring.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
n = 15
np.random.seed(42)
# Random voxels
voxels = np.random.random((n, n, n)) < 0.15
# Full palette colors
palette = [
(0.96, 0.15, 0.42), # coral #F5276C
(0.96, 0.29, 0.15), # orange #F54927
(0.96, 0.69, 0.15), # amber #F5B027
(0.15, 0.83, 0.96), # cyan #27D3F5
(0.15, 0.96, 0.69), # mint #27F5B0
(0.42, 0.96, 0.15), # lime #6CF527
(0.29, 0.15, 0.96), # purple #4927F5
(0.15, 0.42, 0.96), # blue #276CF5
(0.83, 0.96, 0.15), # yellow_lime #D3F527
(0.61, 0.13, 0.03), # dark_red #9C2007
(0.78, 0.16, 0.04), # red #C82909
(0.96, 0.83, 0.15), # yellow #F5D327
(0.96, 0.15, 0.69), # pink #F527B0
(0.33, 0.08, 0.90), # deep_purple #5314E6
]
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0
# Assign random colors from palette
x, y, z = np.indices((n, n, n))
color_idx = (x + y + z) % len(palette)
for i, p in enumerate(palette):
mask = voxels & (color_idx == i)
colors[mask, :3] = p
colors[mask, 3] = 0.9
fig = plt.figure(figsize=(10, 8), facecolor='#020B14')
ax = fig.add_subplot(111, projection='3d', facecolor='#020B14')
ax.voxels(voxels, facecolors=colors, edgecolors='#1e293b', linewidth=0.3)
ax.set_xlabel('X', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_ylabel('Y', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_zlabel('Z', fontsize=11, color='#94a3b8', labelpad=10)
ax.set_title('Random Voxel Scatter', fontsize=14, color='white', fontweight='bold', pad=20)
ax.tick_params(colors='#64748b', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#1e293b')
ax.yaxis.pane.set_edgecolor('#1e293b')
ax.zaxis.pane.set_edgecolor('#1e293b')
ax.grid(True, alpha=0.2, color='#475569')
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Voxels examples
☕