3D Voxels
Rubik's Cube Voxels
Classic 3x3x3 Rubik's cube with standard face colors.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
n = 3
voxels = np.ones((n, n, n), dtype=bool)
# Full CLAUDE.md palette for cube faces
palette = {
'coral': (0.96, 0.15, 0.42), # #F5276C
'orange': (0.96, 0.29, 0.15), # #F54927
'yellow': (0.96, 0.83, 0.15), # #F5D327
'cyan': (0.15, 0.83, 0.96), # #27D3F5
'lime': (0.42, 0.96, 0.15), # #6CF527
'deep_purple': (0.33, 0.08, 0.90) # #5314E6
}
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0.95
# Assign colors based on position
x, y, z = np.indices((n, n, n))
# Top layer - yellow
colors[z == 2, :3] = palette['yellow']
# Bottom layer - coral
colors[z == 0, :3] = palette['coral']
# Front - cyan
colors[y == 0, :3] = palette['cyan']
# Back - lime
colors[y == 2, :3] = palette['lime']
# Left - orange
colors[x == 0, :3] = palette['orange']
# Right - deep_purple
colors[x == 2, :3] = palette['deep_purple']
fig = plt.figure(figsize=(10, 8), facecolor='#020B14')
ax = fig.add_subplot(111, projection='3d', facecolor='#020B14')
ax.voxels(voxels, facecolors=colors, edgecolors='#0a0a0f', linewidth=2)
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("Rubik's Cube Voxels", 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
☕