Sankey Diagram

E-commerce Order Flow

Online order processing flow from checkout through fulfillment to delivery outcomes.

Output
E-commerce Order 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.003

# Orders to processing
draw_flow(ax, 0.5, 5, 2.5, 5, 1000*s, 1000*s, '#F54927', 0.6)

# Processing split
draw_flow(ax, 3.5, 5.5, 5.5, 7.5, 50*s, 50*s, '#C82909', 0.6)   # Cancelled
draw_flow(ax, 3.5, 4.5, 5.5, 4, 950*s, 950*s, '#27D3F5', 0.6)  # Shipped

# Delivery outcomes
draw_flow(ax, 6.5, 4.5, 8.5, 6.5, 900*s, 900*s, '#6CF527', 0.6)  # Delivered
draw_flow(ax, 6.5, 3.5, 8.5, 2, 50*s, 50*s, '#F5B027', 0.6)     # Returned

# Nodes
draw_node(ax, 0, 5, 0.6, 1000*s*1.2, '#F54927', 'Orders\n1000')
draw_node(ax, 3, 5, 0.6, 1000*s*1.2, '#4927F5', 'Processing\n1000')
draw_node(ax, 6, 7.5, 0.6, 50*s*4, '#C82909', 'Cancelled\n50')
draw_node(ax, 6, 4, 0.6, 950*s*1.2, '#27D3F5', 'Shipped\n950')
draw_node(ax, 9, 6.5, 0.6, 900*s*1.2, '#6CF527', 'Delivered\n900')
draw_node(ax, 9, 2, 0.6, 50*s*4, '#F5B027', 'Returned\n50')

ax.set_title('E-commerce Order Fulfillment Flow', fontsize=16, color='#1f2937', 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