Sankey Diagram

Waste Recycling Flow

Municipal waste flow through sorting and recycling processes to material recovery.

Output
Waste Recycling 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='#374151', 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='#ffffff')
ax.set_facecolor('#ffffff')

s = 0.004

# Collection to sorting
draw_flow(ax, 0.5, 5, 2.5, 5, 1000*s, 1000*s, '#6CF527', 0.6)

# Sorting split
draw_flow(ax, 3.5, 5.5, 5.5, 7.5, 200*s, 200*s, '#9C2007', 0.6)  # Landfill
draw_flow(ax, 3.5, 4.5, 5.5, 4, 800*s, 800*s, '#27F5B0', 0.6)   # Recyclable

# Material types
draw_flow(ax, 6.5, 4.8, 8.5, 7, 300*s, 300*s, '#27D3F5', 0.6)   # Paper
draw_flow(ax, 6.5, 4.2, 8.5, 4.5, 250*s, 250*s, '#4927F5', 0.6)  # Plastic
draw_flow(ax, 6.5, 3.5, 8.5, 2.5, 150*s, 150*s, '#F5B027', 0.6)  # Metal
draw_flow(ax, 6.5, 3, 8.5, 0.5, 100*s, 100*s, '#F5276C', 0.6)   # Glass

# Nodes
draw_node(ax, 0, 5, 0.6, 1000*s*1.2, '#6CF527', 'Collected\n1000t')
draw_node(ax, 3, 5, 0.6, 1000*s*1.2, '#27F5B0', 'Sorting\n1000t')
draw_node(ax, 6, 7.5, 0.6, 200*s*2, '#9C2007', 'Landfill\n200t')
draw_node(ax, 6, 4, 0.6, 800*s*1.2, '#27D3F5', 'Recycle\n800t')
draw_node(ax, 9, 7, 0.6, 300*s*1.5, '#27D3F5', 'Paper\n300t')
draw_node(ax, 9, 4.5, 0.6, 250*s*1.6, '#4927F5', 'Plastic\n250t')
draw_node(ax, 9, 2.5, 0.6, 150*s*2, '#F5B027', 'Metal\n150t')
draw_node(ax, 9, 0.5, 0.6, 100*s*3, '#F5276C', 'Glass\n100t')

ax.set_title('Municipal Waste Recycling Flow', fontsize=16, color='#1f2937', fontweight='bold', pad=20)
ax.set_xlim(-1, 10)
ax.set_ylim(-0.5, 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