3D Scatter
E-commerce User Behavior Analysis
User behavior segmentation showing session metrics and conversion with neon status colors.
Output
Python
import matplotlib.pyplot as plt
import numpy as np
np.random.seed(789)
# User behavior: session_duration, pages_viewed, conversion_value
n_users = 200
session_duration = np.random.exponential(5, n_users) + 0.5 # minutes
pages_viewed = np.random.poisson(8, n_users) + 1
conversion_value = np.random.exponential(50, n_users)
# Segment by behavior
converted = conversion_value > 30
bounced = (session_duration < 1) & (pages_viewed < 3)
colors = []
for c, b in zip(converted, bounced):
if c:
colors.append('#6CF527') # Converted - neon lime
elif b:
colors.append('#F54927') # Bounced - neon orange
else:
colors.append('#27D3F5') # Engaged - neon cyan
fig = plt.figure(figsize=(10, 8), facecolor='#ffffff')
ax = fig.add_subplot(111, projection='3d', facecolor='#ffffff')
ax.scatter(session_duration, pages_viewed, conversion_value, c=colors,
s=50, alpha=0.7, edgecolors='#374151', linewidths=0.3)
ax.set_xlabel('Session Duration (min)', color='#1f2937', fontsize=10)
ax.set_ylabel('Pages Viewed', color='#1f2937', fontsize=10)
ax.set_zlabel('Conversion Value ($)', color='#1f2937', fontsize=10)
ax.set_title('E-commerce User Behavior Analysis', 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=35)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
3D Charts
☕