3D Stem
24-Hour Rainfall Distribution
Meteorological data showing rainfall intensity across weather stations over 24 hours.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(111)
# Rainfall data across stations
n = 24
hours = np.arange(n)
stations = np.random.choice([0, 0.3, 0.6, 1], n)
rainfall = np.random.exponential(10, n) * (1 + 0.5 * np.sin(hours * np.pi / 12))
x = hours / 24
y = stations
z = rainfall / rainfall.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='#0891b2', linewidth=2, alpha=0.7)
plt.setp(markerline, color='#06b6d4', markersize=8)
ax.set_xlabel('Time (day fraction)', color='#1f2937', fontsize=10)
ax.set_ylabel('Station', color='#1f2937', fontsize=10)
ax.set_zlabel('Rainfall (normalized)', color='#1f2937', fontsize=10)
ax.set_title('24-Hour Rainfall Distribution', 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=45)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
More 3D Stem examples
☕