3D Stem
Sales by Region and Product
Business analytics showing sales performance across regions and product categories.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(666)
# Sales data matrix
n_regions = 5
n_products = 6
n = n_regions * n_products
regions = np.repeat(np.arange(n_regions), n_products)
products = np.tile(np.arange(n_products), n_regions)
sales = np.random.exponential(100, n) * (1 + 0.3 * regions)
x = regions / n_regions
y = products / n_products
z = sales / sales.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='#22c55e', linewidth=2, alpha=0.7)
plt.setp(markerline, color='#4ade80', markersize=8)
ax.set_xlabel('Region', color='#1f2937', fontsize=10)
ax.set_ylabel('Product', color='#1f2937', fontsize=10)
ax.set_zlabel('Sales (normalized)', color='#1f2937', fontsize=10)
ax.set_title('Sales by Region and Product', 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
☕