Skip to main content

StripPlot

Builder for creating strip plots (also called dot plots or univariate scatter). Each group is rendered as a vertical cloud of points along a categorical x-axis. Three layout modes are available:
MethodLayoutBest for
with_jitter(j)Random horizontal jitterLarge N; fast
with_swarm()Non-overlapping beeswarmN < ~200; clearest structure
with_center()All at centerDensity columns; stacked look
Multiple StripPlots can be layered on the same canvas (e.g. with a BoxPlot) by passing them together to render_multiple.

Constructor

StripPlot::new()
Self
Create a strip plot with default settings.Defaults:
  • Color: "steelblue"
  • Point size: 4.0 pixels
  • Jitter: 0.3
  • Seed: 42

Data Methods

with_group
Self
pub fn with_group<S, I>(self, label: S, values: I) -> Self
where
    S: Into<String>,
    I: IntoIterator,
    I::Item: Into<f64>
Add a group (one column of points) with a label and values. Groups are rendered left-to-right in the order they are added.Example:
let strip = StripPlot::new()
    .with_group("Control",   vec![4.1, 5.0, 5.3, 5.8])
    .with_group("Treatment", vec![6.1, 6.4, 7.2, 7.8]);

Styling Methods

with_color
Self
pub fn with_color<S: Into<String>>(self, color: S) -> Self
Set the point fill color (default "steelblue"). Use an rgba(...) value to make points semi-transparent when overlaying on a box plot or violin.
with_point_size
Self
pub fn with_point_size(self, size: f64) -> Self
Set the point radius in pixels (default 4.0). Reduce for large datasets (e.g. 2.03.0) to limit overlap.

Layout Methods

with_jitter
Self
pub fn with_jitter(self, jitter: f64) -> Self
Use a jittered strip layout with the given horizontal spread. jitter is the half-width as a fraction of the category slot width. 0.3 (the default) spreads points ±30% of the slot. Increase to spread points further apart; decrease to tighten the column. The position is randomised using with_seed.Example:
let strip = StripPlot::new()
    .with_group("A", vec![1.0, 2.0, 3.0])
    .with_jitter(0.4);   // wider spread
with_swarm
Self
pub fn with_swarm(self) -> Self
Use a beeswarm (non-overlapping) layout. Points are placed as close to the group center as possible without overlapping. The resulting outline traces the density of the distribution. Works best for N < ~200 per group; with very large datasets points will be pushed far from center.
with_center
Self
pub fn with_center(self) -> Self
Place all points at the group center (no horizontal spread). Creates a vertical column of overlapping points. Useful when you want to show the full data cloud without any jitter artifact, or when combining with a violin to show individual points on the density axis.
with_seed
Self
pub fn with_seed(self, seed: u64) -> Self
Set the RNG seed used for jitter positions (default 42). Change the seed to get a different random arrangement while keeping the output reproducible.

Legend Methods

with_legend
Self
pub fn with_legend<S: Into<String>>(self, label: S) -> Self
Attach a legend label to this strip plot.

Enums & Types

StripStyle

Controls how points are spread horizontally within each group slot.
  • Strip { jitter: f64 } - Random horizontal jitter. jitter is the half-width as a fraction of the category slot width.
  • Swarm - Deterministic beeswarm: points are placed as close to center as possible without overlapping. Best for N < ~200 per group.
  • Center - No horizontal spread — all points placed at the group center. Creates a vertical density column.

StripGroup

One group (one column of points) within a strip plot. Fields:
  • label: String - Group label
  • values: Vec<f64> - Data values

Complete Example

Jittered Strip Plot

use kuva::plot::StripPlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_multiple;
use kuva::render::layout::Layout;
use kuva::render::plots::Plot;

let strip = StripPlot::new()
    .with_group("Control",   vec![4.1, 5.0, 5.3, 5.8, 6.2, 4.7, 5.5])
    .with_group("Treatment", vec![5.5, 6.1, 6.4, 7.2, 7.8, 6.9, 7.0])
    .with_color("steelblue")
    .with_jitter(0.3)
    .with_point_size(3.0);

let plots = vec![Plot::Strip(strip)];
let layout = Layout::auto_from_plots(&plots)
    .with_title("Control vs. Treatment")
    .with_x_label("Group")
    .with_y_label("Value");

let svg = SvgBackend.render_scene(&render_multiple(plots, layout));
std::fs::write("strip.svg", svg).unwrap();

Beeswarm Strip Plot

use kuva::plot::StripPlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_multiple;
use kuva::render::layout::Layout;
use kuva::render::plots::Plot;

let strip = StripPlot::new()
    .with_group("Control",   vec![4.1, 5.0, 5.3, 5.8, 6.2, 4.7, 5.5])
    .with_group("Treatment", vec![5.5, 6.1, 6.4, 7.2, 7.8, 6.9, 7.0])
    .with_color("steelblue")
    .with_swarm()
    .with_point_size(3.0);

let plots = vec![Plot::Strip(strip)];
let layout = Layout::auto_from_plots(&plots)
    .with_title("Control vs. Treatment (beeswarm)")
    .with_x_label("Group")
    .with_y_label("Value");

let svg = SvgBackend.render_scene(&render_multiple(plots, layout));
std::fs::write("strip_swarm.svg", svg).unwrap();

Centered Strip Plot

use kuva::plot::StripPlot;
use kuva::backend::svg::SvgBackend;
use kuva::render::render::render_multiple;
use kuva::render::layout::Layout;
use kuva::render::plots::Plot;

let strip = StripPlot::new()
    .with_group("Control",   vec![4.1, 5.0, 5.3, 5.8, 6.2, 4.7, 5.5])
    .with_group("Treatment", vec![5.5, 6.1, 6.4, 7.2, 7.8, 6.9, 7.0])
    .with_color("rgba(70,130,180,0.5)")
    .with_center()
    .with_point_size(4.0);

let plots = vec![Plot::Strip(strip)];
let layout = Layout::auto_from_plots(&plots)
    .with_title("Control vs. Treatment (centered)")
    .with_x_label("Group")
    .with_y_label("Value");

let svg = SvgBackend.render_scene(&render_multiple(plots, layout));
std::fs::write("strip_center.svg", svg).unwrap();

Build docs developers (and LLMs) love