Skip to content

Beeswarm

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

Beeswarm

Usage

from dataviz import beeswarm
from dataviz import save

def main() raises:
    var regions: List[String] = ["US East", "EU West", "Asia Pacific"]
    # The same illustrative latency sample used by box() and violin(),
    # with every request visible instead of summarized or smoothed.
    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 = beeswarm(
        regions,
        latency_ms,
        title="Illustrative API Latency by Region",
        x_title="Region",
        y_title="Latency (ms)",
    )
    save(c, "docs/src/examples/out_beeswarm.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.
  • 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.
  • horizontal: Draw the categories down the y axis instead.

Related

Related charts: Violin · Ridgeline

Relevant API: beeswarm