3D Stem
Gene Expression Time Course
Transcriptomics data showing gene expression levels across time points.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(222)
# Gene expression over time
n_timepoints = 8
n_genes = 4
n = n_timepoints * n_genes
timepoints = np.tile(np.arange(n_timepoints), n_genes)
genes = np.repeat(np.arange(n_genes), n_timepoints)
expression = np.random.exponential(1, n) * (1 + 0.5 * np.sin(timepoints * np.pi / 4))
x = timepoints / n_timepoints
y = genes / n_genes
z = expression / expression.max()
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
markerline, stemlines, baseline = ax.stem(x, y, z, linefmt='-', markerfmt='o', basefmt=' ')
plt.setp(stemlines, color='#8b5cf6', linewidth=1.5, alpha=0.7)
plt.setp(markerline, color='#a78bfa', markersize=7)
ax.set_xlabel('Time (normalized)', color='#1f2937', fontsize=10)
ax.set_ylabel('Gene ID', color='#1f2937', fontsize=10)
ax.set_zlabel('Expression Level', color='#1f2937', fontsize=10)
ax.set_title('Gene Expression Time Course', color='#1f2937', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#6b7280', labelsize=8)
ax.xaxis.pane.fill = False
ax.yaxis.pane.fill = False
ax.zaxis.pane.fill = False
ax.xaxis.pane.set_edgecolor('#e5e7eb')
ax.yaxis.pane.set_edgecolor('#e5e7eb')
ax.zaxis.pane.set_edgecolor('#e5e7eb')
ax.view_init(elev=25, azim=40)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Stem examples
☕