Ridgeline Plot

Cloud Function Execution Time

Serverless performance with electric blue theme

Output
Cloud Function Execution Time
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy import stats

np.random.seed(1010)

functions = ['Auth', 'Payment', 'Search', 'Upload', 'Notify', 'Report']
colors = ['#27D3F5', '#6CF527', '#F5B027', '#F5276C', '#4927F5', '#27F5B0']

data = {
    'Auth': np.random.lognormal(2, 0.5, 500),
    'Payment': np.random.lognormal(3, 0.6, 500),
    'Search': np.random.lognormal(2.5, 0.55, 500),
    'Upload': np.random.lognormal(4, 0.8, 500),
    'Notify': np.random.lognormal(1.5, 0.4, 500),
    'Report': np.random.lognormal(4.5, 0.9, 500)
}

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

overlap = 1.7
x_range = np.linspace(0, 200, 300)

for i, (func, time) in enumerate(data.items()):
    time = np.clip(time, 0, 200)
    kde = stats.gaussian_kde(time, bw_method=0.3)
    y = kde(x_range) * 4
    baseline = i * overlap
    
    for w, a in [(14, 0.08), (10, 0.12), (6, 0.22), (3, 0.45)]:
        ax.plot(x_range, y + baseline, color=colors[i], linewidth=w, alpha=a)
    
    ax.fill_between(x_range, baseline, y + baseline, alpha=0.45, color=colors[i])
    ax.plot(x_range, y + baseline, color='white', linewidth=1.2, alpha=0.9)
    
    ax.text(-5, baseline + 0.15, func, fontsize=11, color=colors[i],
            ha='right', va='bottom', fontweight='600')

ax.set_xlim(-30, 200)
ax.set_ylim(-0.3, len(functions) * overlap + 2)
ax.set_xlabel('Execution Time (ms)', fontsize=12, color='#555555', fontweight='500')
ax.set_title('Cloud Function Execution Time', fontsize=16, color='white', fontweight='bold', pad=20)

ax.tick_params(axis='x', colors='#444444', labelsize=10)
ax.tick_params(axis='y', left=False, labelleft=False)
for spine in ax.spines.values():
    spine.set_visible(False)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support