Ridgeline Plot

CPU Usage Patterns by Server

Server CPU utilization distributions across infrastructure

Output
CPU Usage Patterns by Server
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(42)
servers = ['web-01', 'web-02', 'api-01', 'api-02', 'db-01', 'cache-01']
cpu_means = [45, 52, 68, 72, 35, 28]
cpu_stds = [15, 18, 12, 14, 10, 8]

fig, ax = plt.subplots(figsize=(12, 8), facecolor='#0a0a0f')
ax.set_facecolor('#0a0a0f')

colors = ['#27D3F5', '#27F5B0', '#6CF527', '#F5B027', '#F54927', '#F5276C']

x = np.linspace(0, 100, 200)
overlap = 2.2

for i, (server, mean, std, color) in enumerate(zip(servers, cpu_means, cpu_stds, colors)):
    data = np.random.normal(mean, std, 1000)
    data = np.clip(data, 0, 100)
    kde = stats.gaussian_kde(data)
    y = kde(x) * 8
    y_offset = i * overlap
    
    ax.fill_between(x, y_offset, y + y_offset, alpha=0.85, color=color, edgecolor='white', linewidth=0.8)
    ax.text(-5, y_offset + 0.3, server, fontsize=10, color='white', va='center', ha='right', fontweight='500', family='monospace')

ax.set_xlim(-25, 100)
ax.set_ylim(-0.5, len(servers) * overlap + 2)
ax.set_xlabel('CPU Usage (%)', color='white', fontsize=11, fontweight='500')
ax.set_title('CPU Usage Distribution by Server', color='white', fontsize=14, fontweight='bold', pad=20)
ax.tick_params(colors='#888888', labelsize=9)
ax.set_yticks([])
for spine in ax.spines.values():
    spine.set_visible(False)
ax.spines['bottom'].set_visible(True)
ax.spines['bottom'].set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support