Dendrogram

Network Traffic Clusters

Cybersecurity traffic pattern analysis

Output
Network Traffic Clusters
Python
import matplotlib.pyplot as plt
import numpy as np
from scipy.cluster.hierarchy import dendrogram, linkage, set_link_color_palette

np.random.seed(444)

traffic_types = ['HTTP', 'HTTPS', 'SSH', 'FTP', 'DNS', 'SMTP', 'IMAP',
                 'POP3', 'RDP', 'VNC', 'Telnet', 'SNMP']

data = np.random.randn(len(traffic_types), 7)

Z = linkage(data, method='ward')

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

set_link_color_palette(['#6CF527', '#27D3F5', '#F5B027', '#F5276C'])

dn = dendrogram(Z, labels=traffic_types, leaf_rotation=45, leaf_font_size=10,
                color_threshold=5, above_threshold_color='#444444', ax=ax)

ax.axhline(y=5, color='#6CF527', linestyle='--', linewidth=1.5, alpha=0.7)

ax.set_title('Network Protocol Clustering', color='white', fontsize=14, fontweight='bold', pad=15)
ax.set_ylabel('Behavioral Distance', color='#888888', fontsize=11)

ax.tick_params(axis='both', colors='white', labelsize=9)
for spine in ax.spines.values():
    spine.set_color('#333333')
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)

plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Statistical

Did this help you?

Support PyLucid to keep it free & growing

Support