Waterfall Plot Gallery¶
Waterfall plots are used for visualizing how different positive and negative values contribute to a cumulative total. They're perfect for showing incremental changes, financial breakdowns, and performance analysis.
Waterfall plots excel at:
- Financial Analysis: Track how revenues, costs, and profits contribute to totals
- Performance Breakdown: Show how different factors impact overall metrics
- Change Analysis: Visualize step-by-step changes from starting to ending values
- Budget Tracking: Display how various categories affect total budgets
In [ ]:
Copied!
import matplotlib.pyplot as plt
from pyretailscience.plots import waterfall
import matplotlib.pyplot as plt
from pyretailscience.plots import waterfall
Basic Waterfall Chart¶
Create a basic waterfall chart using lists of amounts and labels. Positive values appear as green bars, negative values as red bars.
In [ ]:
Copied!
# Create sample financial data
amounts = [100, 25, -15, 10, -8, 12]
labels = ["Starting Revenue", "New Sales", "Refunds", "Upsells", "Discounts", "Bonuses"]
waterfall.plot(
amounts=amounts,
labels=labels,
title="Revenue Changes",
y_label="Revenue ($000s)",
figsize=(10, 6),
)
plt.show()
# Create sample financial data
amounts = [100, 25, -15, 10, -8, 12]
labels = ["Starting Revenue", "New Sales", "Refunds", "Upsells", "Discounts", "Bonuses"]
waterfall.plot(
amounts=amounts,
labels=labels,
title="Revenue Changes",
y_label="Revenue ($000s)",
figsize=(10, 6),
)
plt.show()
Data Label Formats¶
Use data_label_format to control how values are displayed: "absolute", "percentage", or "both".
In [ ]:
Copied!
# Create sample cost breakdown data
amounts = [50, -12, -8, -15, -3, 7]
labels = ["Gross Profit", "Marketing", "Operations", "Staff Costs", "Technology", "Savings"]
waterfall.plot(
amounts=amounts,
labels=labels,
data_label_format="both", # Show both absolute values and percentages
title="Cost Impact Analysis",
y_label="Impact ($000s)",
figsize=(10, 6),
)
plt.show()
# Create sample cost breakdown data
amounts = [50, -12, -8, -15, -3, 7]
labels = ["Gross Profit", "Marketing", "Operations", "Staff Costs", "Technology", "Savings"]
waterfall.plot(
amounts=amounts,
labels=labels,
data_label_format="both", # Show both absolute values and percentages
title="Cost Impact Analysis",
y_label="Impact ($000s)",
figsize=(10, 6),
)
plt.show()
In [ ]:
Copied!
# Create sample performance metrics
amounts = [20, 8, -5, 12, -3]
labels = ["Q1 Sales", "Q2 Growth", "Q3 Decline", "Q4 Recovery", "Adjustments"]
waterfall.plot(
amounts=amounts,
labels=labels,
display_net_bar=True, # Show net total bar
title="Quarterly Performance Summary",
y_label="Performance Score",
figsize=(10, 6),
)
plt.show()
# Create sample performance metrics
amounts = [20, 8, -5, 12, -3]
labels = ["Q1 Sales", "Q2 Growth", "Q3 Decline", "Q4 Recovery", "Adjustments"]
waterfall.plot(
amounts=amounts,
labels=labels,
display_net_bar=True, # Show net total bar
title="Quarterly Performance Summary",
y_label="Performance Score",
figsize=(10, 6),
)
plt.show()
Net Line Display¶
Use display_net_line=True to show a horizontal line indicating the final total value.
In [ ]:
Copied!
# Create sample budget variance data
amounts = [100, -25, 15, -10, 8, -12]
labels = ["Budget", "Overspend", "Savings", "Emergency", "Rebate", "Fees"]
waterfall.plot(
amounts=amounts,
labels=labels,
display_net_line=True, # Show net total line
data_label_format="absolute",
title="Budget Variance Analysis",
y_label="Amount ($000s)",
figsize=(10, 6),
)
plt.show()
# Create sample budget variance data
amounts = [100, -25, 15, -10, 8, -12]
labels = ["Budget", "Overspend", "Savings", "Emergency", "Rebate", "Fees"]
waterfall.plot(
amounts=amounts,
labels=labels,
display_net_line=True, # Show net total line
data_label_format="absolute",
title="Budget Variance Analysis",
y_label="Amount ($000s)",
figsize=(10, 6),
)
plt.show()
Remove Zero Amounts¶
Use remove_zero_amounts=False to include zero values in the chart (they are excluded by default).
In [ ]:
Copied!
# Create sample data with zero values
amounts = [80, 15, 0, -10, 0, 5, -8]
labels = ["Revenue", "Growth", "No Change", "Returns", "Flat", "Bonus", "Costs"]
waterfall.plot(
amounts=amounts,
labels=labels,
remove_zero_amounts=False, # Include zero amounts
title="Complete Change Analysis",
y_label="Change ($000s)",
figsize=(10, 6),
)
plt.show()
# Create sample data with zero values
amounts = [80, 15, 0, -10, 0, 5, -8]
labels = ["Revenue", "Growth", "No Change", "Returns", "Flat", "Bonus", "Costs"]
waterfall.plot(
amounts=amounts,
labels=labels,
remove_zero_amounts=False, # Include zero amounts
title="Complete Change Analysis",
y_label="Change ($000s)",
figsize=(10, 6),
)
plt.show()