3D Voxels
Atomic Model Voxels
Simplified atomic model with nucleus and electron shells in coral-mint colors.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
n = 15
x, y, z = np.indices((n, n, n))
cx, cy, cz = n // 2, n // 2, n // 2
# Nucleus (sphere)
nucleus = ((x - cx)**2 + (y - cy)**2 + (z - cz)**2) <= 4
# Electron orbits (rings)
orbit1 = (np.abs((x - cx)**2 + (y - cy)**2 - 25) <= 2) & (np.abs(z - cz) <= 1)
orbit2 = (np.abs((x - cx)**2 + (z - cz)**2 - 25) <= 2) & (np.abs(y - cy) <= 1)
orbit3 = (np.abs((y - cy)**2 + (z - cz)**2 - 25) <= 2) & (np.abs(x - cx) <= 1)
voxels = nucleus | orbit1 | orbit2 | orbit3
# Colors: deep_purple nucleus, yellow orbits
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0
# Nucleus - deep_purple #5314E6
colors[nucleus, 0] = 0.33
colors[nucleus, 1] = 0.08
colors[nucleus, 2] = 0.90
colors[nucleus, 3] = 0.95
# Orbits - yellow #F5D327
orbits = orbit1 | orbit2 | orbit3
colors[orbits, 0] = 0.96
colors[orbits, 1] = 0.83
colors[orbits, 2] = 0.15
colors[orbits, 3] = 0.8
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.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('Atomic Model 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
☕