3D Voxels
3D Arrow Voxels
Directional arrow pointing upward with cyan-blue gradient.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
n = 15
voxels = np.zeros((n, n, n), dtype=bool)
cx, cy = n // 2, n // 2
# Arrow shaft
voxels[cx-1:cx+2, cy-1:cy+2, 0:8] = True
# Arrow head (cone)
for z in range(8, n):
r = (n - z)
if r > 0:
voxels[cx-r:cx+r+1, cy-r:cy+r+1, z] = True
# Red #C82909 gradient
z_idx = np.indices((n, n, n))[2]
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0
norm_z = z_idx / (n - 1)
# C82909 with brightness variation
colors[voxels, 0] = 0.78 + 0.18 * norm_z[voxels]
colors[voxels, 1] = 0.16 + 0.13 * norm_z[voxels]
colors[voxels, 2] = 0.04 + 0.11 * norm_z[voxels]
colors[voxels, 3] = 0.9
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('Arrow Pointer 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
☕