Skip to content

Ridgeline

ridgeline() over a long-form dataframe_mojo DataFrame (#743): one row per observation, with category naming each row’s group and value holding the number.

Ridgeline

Usage

from dataviz import ridgeline
from dataviz import save

def main() raises:
    var regions: List[String] = ["US East", "EU West", "Asia Pacific"]
    # The shared illustrative regional latency sample, arranged as
    # overlapping density ridges for compact shape comparison.
    var latency_ms: List[List[Int]] = [
        [68, 72, 75, 71, 69, 74, 78, 73, 70, 76, 82, 77, 71, 69, 80, 74, 72, 75, 118, 67],
        [96, 102, 108, 99, 104, 111, 106, 101, 98, 115, 109, 103, 107, 100, 113, 105, 97, 110, 146, 102],
        [154, 162, 171, 158, 166, 179, 173, 160, 168, 181, 176, 164, 170, 157, 184, 169, 161, 175, 238, 165],
    ]

    var c = ridgeline(
        regions,
        latency_ms,
        title="Illustrative API Latency by Region",
        x_title="Latency (ms)",
        y_title="Region",
    )
    save(c, "docs/src/examples/out_ridgeline.svg")

See Data shapes for shared input conventions.

Args:

  • df: The frame to read.
  • category: The string column naming each observation’s group.
  • value: The numeric column holding the observations.
  • bandwidth: Kernel bandwidth; see the list overload.
  • scale_by_count: Scale each ridge by its sample count.
  • overlap: How far each ridge rides over the next.
  • theme: Full styling knobs beyond this function’s own parameters.
  • width: Pixel width of the returned Plot (.size()).
  • height: Pixel height of the returned Plot (.size()).
  • title: The chart’s title, shown above the plot.
  • subtitle: A line under the title.
  • x_title: The x-axis caption; defaults to category.
  • y_title: The y-axis caption; defaults to value.

Related

Related charts: Beeswarm · Density Curve

Relevant API: ridgeline