Sankey Diagram

Network Security Flow

Network traffic flow through security layers showing threat detection and filtering stages.

Output
Network Security Flow
Python
import matplotlib.pyplot as plt
import matplotlib.patches as mpatches
from matplotlib.path import Path

def draw_flow(ax, x0, y0, x1, y1, w0, w1, color, alpha=0.6):
    cx = (x0 + x1) / 2
    verts = [
        (x0, y0 + w0/2), (cx, y0 + w0/2), (cx, y1 + w1/2), (x1, y1 + w1/2),
        (x1, y1 - w1/2), (cx, y1 - w1/2), (cx, y0 - w0/2), (x0, y0 - w0/2),
        (x0, y0 + w0/2)
    ]
    codes = [Path.MOVETO] + [Path.CURVE4]*3 + [Path.LINETO] + [Path.CURVE4]*3 + [Path.CLOSEPOLY]
    ax.add_patch(mpatches.PathPatch(Path(verts, codes), fc=color, alpha=alpha, ec='none'))

def draw_node(ax, x, y, w, h, color, label):
    ax.add_patch(mpatches.FancyBboxPatch((x-w/2, y-h/2), w, h, boxstyle="round,pad=0.02",
                                          fc=color, ec='white', lw=1.5))
    ax.text(x, y, label, ha='center', va='center', fontsize=8, color='white', fontweight='bold')

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

s = 0.0006

# Internet to firewall
draw_flow(ax, 0.5, 5, 2.5, 5, 10000*s, 10000*s, '#F54927', 0.7)

# Firewall outputs
draw_flow(ax, 3.5, 5.5, 5.5, 7.5, 2000*s, 2000*s, '#C82909', 0.7)  # Blocked
draw_flow(ax, 3.5, 4.5, 5.5, 4, 8000*s, 8000*s, '#6CF527', 0.7)   # Passed

# IDS outputs
draw_flow(ax, 6.5, 4.5, 8.5, 6.5, 500*s, 500*s, '#F5B027', 0.7)   # Flagged
draw_flow(ax, 6.5, 3.5, 8.5, 3, 7500*s, 7500*s, '#27D3F5', 0.7)   # Clean

# Nodes
draw_node(ax, 0, 5, 0.6, 10000*s*1.1, '#F54927', 'Internet\n10 Gbps')
draw_node(ax, 3, 5, 0.6, 10000*s*1.1, '#4927F5', 'Firewall\n10 Gbps')
draw_node(ax, 6, 7.5, 0.6, 2000*s*1.5, '#C82909', 'Blocked\n2 Gbps')
draw_node(ax, 6, 4, 0.6, 8000*s*1.2, '#6CF527', 'IDS\n8 Gbps')
draw_node(ax, 9, 6.5, 0.6, 500*s*3, '#F5B027', 'Flagged\n0.5 Gbps')
draw_node(ax, 9, 3, 0.6, 7500*s*1.2, '#27D3F5', 'Clean\n7.5 Gbps')

ax.set_title('Network Security Traffic Flow', fontsize=16, color='white', fontweight='bold', pad=20)
ax.set_xlim(-1, 10)
ax.set_ylim(0, 9)
ax.axis('off')
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Part-to-Whole

Did this help you?

Support PyLucid to keep it free & growing

Support