3D Voxels

Mushroom Cloud Voxels

Mushroom shape with stem and cap in orange-red gradient.

Output
Mushroom Cloud Voxels
Python
import matplotlib.pyplot as plt
import numpy as np

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

# Torus: distance from center ring
R = 6  # Major radius
r = 2  # Minor radius

# Distance from z-axis
dist_xy = np.sqrt((x - cx)**2 + (y - cy)**2)
# Distance from torus center ring
torus = (np.sqrt((dist_xy - R)**2 + (z - cz)**2) <= r)

# Gradient from pink #F527B0 to coral #F5276C
colors = np.empty(torus.shape + (4,), dtype=np.float32)
colors[..., 3] = 0

angle = np.arctan2(y - cy, x - cx)
norm_angle = (angle + np.pi) / (2 * np.pi)

# F527B0 -> F5276C
colors[torus, 0] = 0.96  # F5 (constant)
colors[torus, 1] = 0.15  # 27 (constant)
colors[torus, 2] = 0.69 - 0.27 * norm_angle[torus]  # B0 to 6C
colors[torus, 3] = 0.9

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

ax.voxels(torus, 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('Torus 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