3D Stem

User Session Behavior

Web analytics showing user engagement events throughout session with page depth.

Output
User Session Behavior
Python
import matplotlib.pyplot as plt
import numpy as np

np.random.seed(258)

# Web analytics session data
n_events = 30
session_time = np.cumsum(np.random.exponential(30, n_events))  # seconds
page_depth = np.random.randint(1, 8, n_events)
engagement = np.random.uniform(0.2, 1, n_events)

x = session_time / session_time.max()
y = page_depth / 8
z = engagement

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='#ec4899', linewidth=1.5, alpha=0.7)
plt.setp(markerline, color='#f472b6', markersize=7)

ax.set_xlabel('Session Time', color='#1f2937', fontsize=10)
ax.set_ylabel('Page Depth', color='#1f2937', fontsize=10)
ax.set_zlabel('Engagement', color='#1f2937', fontsize=10)
ax.set_title('User Session Behavior', 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