Bar Chart

Waterfall Light

Waterfall chart with clean light theme

Output
Waterfall Light
Python
import matplotlib.pyplot as plt
import numpy as np

labels = ['Beginning', 'Revenue', 'Expenses', 'Tax', 'Investment', 'Ending']
values = [500, 250, -180, -45, 75, 0]

cumulative = [0]
for v in values[:-1]:
    cumulative.append(cumulative[-1] + v)
values[-1] = cumulative[-1] + values[-2]

fig, ax = plt.subplots(figsize=(10, 6), facecolor='#ffffff')
ax.set_facecolor('#ffffff')

x = np.arange(len(labels))
colors = []
for i, v in enumerate(values[:-1]):
    if i == 0:
        colors.append('#6366f1')
    elif v >= 0:
        colors.append('#22c55e')
    else:
        colors.append('#ef4444')
colors.append('#8b5cf6')

bottoms = [0] + cumulative[:-1]
heights = [values[0]] + [v for v in values[1:-1]] + [values[-1]]
bottoms[-1] = 0

bars = ax.bar(x, heights, bottom=bottoms, width=0.55, color=colors, edgecolor='none')

for i in range(len(labels)-1):
    top = bottoms[i] + heights[i]
    ax.plot([i+0.28, i+0.72], [top, top], color='#d1d5db', linewidth=1.5, linestyle='--')

for i, (bar, v) in enumerate(zip(bars, heights)):
    y = bar.get_y() + bar.get_height()/2
    label = f'+{int(v)}' if v > 0 and i > 0 and i < len(labels)-1 else str(int(v))
    ax.text(i, y, label, ha='center', va='center', color='white', fontsize=10, fontweight='bold')

ax.set_xticks(x)
ax.set_xticklabels(labels, color='#374151', fontsize=10)
ax.set_ylabel('Value (K)', color='#6b7280', fontsize=11)

ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#e5e7eb')
ax.spines['bottom'].set_color('#e5e7eb')
ax.tick_params(axis='both', colors='#6b7280', labelsize=9)
ax.yaxis.grid(True, color='#f3f4f6', linewidth=1)
ax.set_axisbelow(True)

ax.set_title('Financial Waterfall', color='#1f2937', fontsize=14, fontweight='bold', pad=15)
plt.tight_layout()
plt.show()
Library

Matplotlib

Category

Basic Charts

Did this help you?

Support PyLucid to keep it free & growing

Support