Skip to content

Tree

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

Tree

Usage

from dataviz import tree
from dataviz import save

def main() raises:
    var ids: List[String] = [
        "CEO", "Product", "Engineering", "Go-to-Market", "Operations",
        "Design", "Research", "Platform", "Applications",
        "Sales", "Success", "Finance", "People",
    ]
    var parent_ids: List[String] = [
        "", "CEO", "CEO", "CEO", "CEO",
        "Product", "Product", "Engineering", "Engineering",
        "Go-to-Market", "Go-to-Market",
        "Operations", "Operations",
    ]
    # Tree layout uses the relationships; unit leaf values keep each
    # team at equal visual weight.
    var values: List[Int] = [
        0, 0, 0, 0, 0, 1, 1, 1, 1, 1, 1, 1, 1,
    ]

    var c = tree(
        ids, parent_ids, values, title="Illustrative Company Organization"
    )
    save(c, "docs/src/examples/out_tree.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • ids: The string column for this channel.
  • parent_ids: The string column for this channel.
  • values: The numeric column for this channel.
  • 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: Sunburst · Treemap

Relevant API: tree