3D Voxels

Pyramid Voxels

3D stepped pyramid structure with amber-orange gradient on dark background.

Output
Pyramid Voxels
Python
import matplotlib.pyplot as plt
import numpy as np

# Prepare coordinates
n = 12
x, y, z = np.indices((n, n, n))

# Pyramid - each layer gets smaller
pyramid = np.zeros((n, n, n), dtype=bool)
for level in range(n // 2):
    margin = level
    pyramid[margin:n-margin, margin:n-margin, level] = True

# Color gradient: dark_red #9C2007 -> red #C82909 -> orange #F54927
colors = np.empty(pyramid.shape + (4,), dtype=np.float32)
norm_z = z / (n - 1)
colors[..., 0] = 0.61 + 0.35 * norm_z  # R (9C to F5)
colors[..., 1] = 0.13 + 0.16 * norm_z  # G (20 to 49)
colors[..., 2] = 0.03 + 0.12 * norm_z  # B (07 to 27)
colors[..., 3] = 0.9

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

ax.voxels(pyramid, facecolors=colors, edgecolor='#ffffff15', linewidth=0.2)

ax.set_xlabel('X', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_ylabel('Y', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_zlabel('Z', fontsize=10, color='#94a3b8', labelpad=10)
ax.set_title("Pyramid 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.view_init(elev=30, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support