3D Voxels

Diamond Crystal Voxels

Elongated diamond crystal shape with blue-purple gradient.

Output
Diamond Crystal Voxels
Python
import matplotlib.pyplot as plt
import numpy as np

n = 11
voxels = np.zeros((n, n, n), dtype=bool)
cx, cy, cz = n // 2, n // 2, n // 2

# Create 3D plus sign
voxels[cx-1:cx+2, :, cz-1:cz+2] = True  # Horizontal bar
voxels[:, cy-1:cy+2, cz-1:cz+2] = True  # Depth bar
voxels[cx-1:cx+2, cy-1:cy+2, :] = True  # Vertical bar

# Gradient using lime #6CF527 with alpha variation
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0

dist = np.sqrt((np.indices((n, n, n))[0] - cx)**2 + 
               (np.indices((n, n, n))[1] - cy)**2 + 
               (np.indices((n, n, n))[2] - cz)**2)
max_dist = np.sqrt(3 * (n//2)**2)
norm_dist = dist / max_dist

# Lime #6CF527
colors[voxels, 0] = 0.42
colors[voxels, 1] = 0.96
colors[voxels, 2] = 0.15
colors[voxels, 3] = 0.95 - 0.3 * norm_dist[voxels]

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('3D Plus Sign 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