Clustermap

Security Vulnerability Clustermap

Attack vectors and vulnerability correlations across systems

Output
Security Vulnerability Clustermap
Python
import matplotlib.pyplot as plt
import seaborn as sns
import pandas as pd
import numpy as np
from matplotlib.colors import LinearSegmentedColormap

np.random.seed(456)

threats = ['SQL Injection', 'XSS', 'CSRF', 'DDoS', 'Phishing', 
           'Malware', 'Ransomware', 'MitM', 'Brute Force', 'Zero-Day']
systems = ['Web App', 'API', 'Database', 'Network', 'Email', 'Endpoint', 'Cloud', 'IoT']

data = np.random.rand(10, 8) * 5
data[0, 2] = 9
data[1, 0] = 8
data[3, 3] = 9
data[6, 5] = 8

df = pd.DataFrame(data, index=threats, columns=systems)

neon_cmap = LinearSegmentedColormap.from_list('threat', ['#0a0a0f', '#4927F5', '#F5B027', '#F5276C', '#C82909'])

g = sns.clustermap(df, cmap=neon_cmap, vmin=0, vmax=10,
                   method='average', metric='euclidean',
                   linewidths=0.5, linecolor='#1a1a2e',
                   figsize=(9, 8), dendrogram_ratio=(0.12, 0.12),
                   cbar_pos=(0.01, 0.08, 0.008, 0.12),
                   annot=True, fmt='.1f', annot_kws={'size': 7, 'color': 'white'},
                   tree_kws={'linewidths': 1.5, 'colors': '#6CF527'})

g.fig.patch.set_facecolor('#0a0a0f')
g.ax_heatmap.set_facecolor('#0a0a0f')
g.ax_heatmap.tick_params(colors='white', labelsize=8)
g.ax_row_dendrogram.set_facecolor('#0a0a0f')
g.ax_col_dendrogram.set_facecolor('#0a0a0f')
g.cax.tick_params(colors='white', labelsize=7)

g.fig.suptitle('Security Risk Assessment', color='white', fontsize=13, fontweight='bold', y=1.02)
plt.show()
Library

Matplotlib

Category

Heatmaps & Density

Did this help you?

Support PyLucid to keep it free & growing

Support