Bar Chart
Waterfall Dark
Waterfall chart showing cumulative effect
Output
Python
import matplotlib.pyplot as plt
import numpy as np
labels = ['Start', 'Sales', 'Services', 'Costs', 'Marketing', 'R&D', 'End']
values = [100, 45, 25, -35, -15, -10, 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='#0a0a0f')
ax.set_facecolor('#0a0a0f')
x = np.arange(len(labels))
colors = []
for i, v in enumerate(values[:-1]):
if i == 0:
colors.append('#27D3F5')
elif v >= 0:
colors.append('#6CF527')
else:
colors.append('#F5276C')
colors.append('#F5B027')
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.6, color=colors, edgecolor='none')
for i in range(len(labels)-1):
top = bottoms[i] + heights[i]
ax.plot([i+0.3, i+0.7], [top, top], color='#444444', linewidth=1, 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='white', fontsize=10)
ax.set_ylabel('Revenue (M)', color='#888888', fontsize=11)
ax.spines['top'].set_visible(False)
ax.spines['right'].set_visible(False)
ax.spines['left'].set_color('#333333')
ax.spines['bottom'].set_color('#333333')
ax.tick_params(axis='both', colors='#888888', labelsize=9)
ax.yaxis.grid(True, color='#1a1a2e', linewidth=0.5)
ax.set_axisbelow(True)
ax.set_title('Revenue Waterfall Analysis', color='white', fontsize=14, fontweight='bold', pad=15)
plt.tight_layout()
plt.show()
Library
Matplotlib
Category
Basic Charts
More Bar Chart examples
☕