2D Histogram

Server Requests vs Response Size

2D histogram of web server request rates versus response payload sizes.

Output
Server Requests vs Response Size
Python
import matplotlib.pyplot as plt
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

np.random.seed(42)

# Server metrics
requests_per_sec = np.random.exponential(100, 5000)
response_size = np.random.exponential(50, 5000) + requests_per_sec * 0.1  # KB

fig, ax = plt.subplots(figsize=(10, 8), facecolor='#020B14')
ax.set_facecolor('#020B14')

# Custom colormap: deep_purple to pink to coral
colors = ['#020B14', '#1a0d2e', '#5314E6', '#F527B0', '#F5276C']
cmap = LinearSegmentedColormap.from_list('server', colors, N=256)

h = ax.hist2d(requests_per_sec, response_size, bins=50, cmap=cmap, cmin=1)
cbar = plt.colorbar(h[3], ax=ax, pad=0.02)
cbar.set_label('Samples', color='white', fontsize=11)
cbar.ax.yaxis.set_tick_params(color='white')
plt.setp(plt.getp(cbar.ax.axes, 'yticklabels'), color='white')

ax.set_xlabel('Requests/sec', fontsize=11, color='white', fontweight='500')
ax.set_ylabel('Response Size (KB)', fontsize=11, color='white', fontweight='500')
ax.set_title('Server Requests vs Response Size', fontsize=14, color='white', fontweight='bold', pad=15)

ax.tick_params(colors='white', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#333333')

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support