3D Voxels

Voxel Cone

Conical voxel structure with orange-amber gradient coloring.

Output
Voxel Cone
Python
import matplotlib.pyplot as plt
import numpy as np

n = 15
x, y, z = np.indices((n, n, n))
cx, cy = n // 2, n // 2

# Cone: radius decreases with height
max_r = 6
cone = np.zeros((n, n, n), dtype=bool)
for zz in range(n):
    r = max_r * (1 - zz / (n - 1))
    cone[:, :, zz] = ((x[:, :, zz] - cx)**2 + (y[:, :, zz] - cy)**2) <= r**2

# Gradient from orange #F54927 to yellow #F5D327
colors = np.empty(cone.shape + (4,), dtype=np.float32)
colors[..., 3] = 0

norm_z = z / (n - 1)
# F54927 -> F5D327
colors[cone, 0] = 0.96  # F5 (constant)
colors[cone, 1] = 0.29 + 0.54 * norm_z[cone]  # 49 to D3
colors[cone, 2] = 0.15  # 27 (constant)
colors[cone, 3] = 0.88

fig = plt.figure(figsize=(10, 8), facecolor='#020B14')
ax = fig.add_subplot(111, projection='3d', facecolor='#020B14')

ax.voxels(cone, facecolors=colors, edgecolors='#1e293b', linewidth=0.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('Voxel Cone', 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