3D Voxels

Helix Tower Voxels

Twisted helical tower structure with purple-pink gradient.

Output
Helix Tower Voxels
Python
import matplotlib.pyplot as plt
import numpy as np

n = 20
voxels = np.zeros((n, n, n), dtype=bool)

# Double helix
for z in range(n):
    angle = z * np.pi / 5
    r = 5
    
    x1 = int(n//2 + r * np.cos(angle))
    y1 = int(n//2 + r * np.sin(angle))
    x2 = int(n//2 + r * np.cos(angle + np.pi))
    y2 = int(n//2 + r * np.sin(angle + np.pi))
    
    if 0 <= x1 < n and 0 <= y1 < n:
        voxels[x1, y1, z] = True
    if 0 <= x2 < n and 0 <= y2 < n:
        voxels[x2, y2, z] = True

# Gradient from mint #27F5B0 to cyan #27D3F5
z_idx = np.indices((n, n, n))[2]
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0

norm_z = z_idx / (n - 1)
# 27F5B0 -> 27D3F5
colors[voxels, 0] = 0.15  # 27 (constant)
colors[voxels, 1] = 0.96 - 0.13 * norm_z[voxels]  # F5 to D3
colors[voxels, 2] = 0.69 + 0.27 * norm_z[voxels]  # B0 to F5
colors[voxels, 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('Helix Tower 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

Did this help you?

Support PyLucid to keep it free & growing

Support