3D Voxels
Spiral Staircase Voxels
Ascending spiral staircase structure with purple-pink gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
# Prepare coordinates
n = 12
x, y, z = np.indices((n, n, n))
# Spiral staircase
staircase = np.zeros((n, n, n), dtype=bool)
center = n // 2
for level in range(n):
angle = level * np.pi / 4
px = int(center + 3 * np.cos(angle))
py = int(center + 3 * np.sin(angle))
staircase[max(0,px-1):min(n,px+2), max(0,py-1):min(n,py+2), level] = True
# Color gradient: deep_purple #5314E6 -> pink #F527B0
colors = np.empty(staircase.shape + (4,), dtype=np.float32)
norm_z = z / (n - 1)
colors[..., 0] = 0.33 + 0.63 * norm_z # R (53 to F5)
colors[..., 1] = 0.08 + 0.07 * norm_z # G (14 to 27)
colors[..., 2] = 0.90 - 0.21 * norm_z # B (E6 to B0)
colors[..., 3] = 0.85
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
ax.voxels(staircase, facecolors=colors, edgecolor='#33333325', linewidth=0.2)
ax.set_xlabel('X', fontsize=10, color='#374151', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#374151', labelpad=10)
ax.set_zlabel('Z', fontsize=10, color='#374151', labelpad=10)
ax.set_title("Spiral Staircase Voxels", fontsize=14, color='#1f2937', fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=30, azim=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Voxels examples
☕