Skip to content

Sankey

sankey() over named columns of a dataframe_mojo DataFrame (#743). Each argument names a column instead of holding the values.

Sankey

Usage

from dataviz import sankey
from dataviz import save
from dataviz import Theme

def main() raises:
    # Illustrative monthly visitor flow from acquisition to outcome.
    var from_stage: List[String] = [
        "Search", "Social", "Email",
        "Landing", "Landing",
        "Browse", "Browse", "Browse",
        "Docs", "Docs", "Trial", "Trial",
    ]
    var to_stage: List[String] = [
        "Landing", "Landing", "Landing",
        "Browse", "Exit",
        "Trial", "Docs", "Exit",
        "Trial", "Exit", "Paid", "Churn",
    ]
    var visitors: List[Int] = [
        420, 260, 180, 610, 250, 310, 180, 120, 90, 90, 190, 210,
    ]

    var c = sankey(
        from_stage,
        to_stage,
        visitors,
        theme=Theme(margin_right=70),
        title="Illustrative Monthly Visitor Journey",
    )
    save(c, "docs/src/examples/out_sankey.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • from_categories: The string column for this channel.
  • to_categories: The string column for this channel.
  • values: The numeric column for this channel.
  • node_width: See the list overload.
  • theme: See the list overload.
  • width: See the list overload.
  • height: See the list overload.
  • title: See the list overload.
  • subtitle: See the list overload.
  • x_title: See the list overload.
  • y_title: See the list overload.

Related

Related charts: Graph

Relevant API: sankey