Skip to content
Waterfall Colors

Waterfall Colors

Use this when: You need to recolor a waterfall’s running-total checkpoint bars and widen its delta bars.

Waterfall Colors

Usage

from dataviz import save, waterfall
from dataviz.core.colors import SLATEGRAY
from dataviz.core.theme import Theme


def main() raises:
    var cats: List[String] = ["Start", "Product", "Services", "Refunds", "End"]
    var deltas: List[Float64] = [50.0, 20.0, 12.0, -10.0, 0.0]
    var is_total: List[Bool] = [True, False, False, False, True]

    var plot = waterfall(
        cats,
        deltas,
        is_total=is_total,
        theme=Theme(waterfall_total_color=SLATEGRAY),
        delta_width_fraction=0.85,
        title="Cash Flow",
        subtitle=(
            "Starting/ending balances in a distinct color, wider delta bars"
        ),
    )
    save(plot, "docs/src/examples/out_waterfall_colors.svg")

Related

Related recipes: Sankey Node Width

Relevant API: Theme · OutputFormat