3D Voxels
3D Letter T Voxels
Three-dimensional letter T structure with gradient purple coloring.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
n = 10
voxels = np.zeros((n, n, n), dtype=bool)
# Top bar of T
voxels[0:3, 3:7, 7:10] = True
# Vertical stem of T
voxels[3:7, 4:6, 0:10] = True
# Gradient from dark_red #9C2007 to red #C82909
colors = np.empty(voxels.shape + (4,), dtype=np.float32)
colors[..., 3] = 0
z = np.indices((n, n, n))[2]
norm_z = z / (n - 1)
# RGB gradient
colors[voxels, 0] = 0.61 + 0.17 * norm_z[voxels] # 9C to C8
colors[voxels, 1] = 0.13 + 0.03 * norm_z[voxels] # 20 to 29
colors[voxels, 2] = 0.03 + 0.02 * norm_z[voxels] # 07 to 09
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.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 Letter T 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
☕