3D Stem

Stock Price & Volume Events

Financial time series showing stock price movements and trading volume as 3D stems.

Output
Stock Price & Volume Events
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(123)

# Stock events over time
n = 25
days = np.arange(n)
price = 100 + np.cumsum(np.random.randn(n) * 2)
volume = np.random.exponential(1, n)

# Normalize for 3D display
x = days / n
y = (price - price.min()) / (price.max() - price.min())
z = volume / volume.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='#3b82f6', linewidth=1.5, alpha=0.7)
plt.setp(markerline, color='#1d4ed8', markersize=8)

ax.set_xlabel('Time (days)', color='#1f2937', fontsize=10)
ax.set_ylabel('Price (normalized)', color='#1f2937', fontsize=10)
ax.set_zlabel('Volume (normalized)', color='#1f2937', fontsize=10)
ax.set_title('Stock Price & Volume Events', 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=20, azim=45)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

3D Charts

Did this help you?

Support PyLucid to keep it free & growing

Support