Repository navigation
kuva v0.1.4
kuva [v0.1.4] — 2026-03-12
Added
- Twin-Y documentation — new
docs/src/plots/twin_y.mdcoveringrender_twin_y,auto_from_twin_y_plots, axis labels, log y2 scale, mixed plot types, palette auto-assignment, and manual range overrides; four SVG examples including a GC bias QC chart. - Per-point colors on
StripPlot—with_colored_group(label, iter_of_(value, color)_pairs)adds a group where each point carries its own color. Colors are matched by position; points beyond the color list fall back to the group/uniform color. Useful when each observation belongs to a distinct category (e.g. motif type) and needs to be visually distinguished within a single column. PolarPlot— polar coordinate scatter/line plot with configurable radial/angular grid, compass (θ=0 north, CW) or math (θ=0 east, CCW) conventions. Supports multiple labeled series, r-max override, r-value labels, spoke angle labels. CLI:kuva polar --r <COL> --theta <COL> [--color-by <COL>] [--mode scatter|line] [--r-max <F>] [--theta-divisions <N>] [--theta-start <DEG>]. Closes #25.TernaryPlot— ternary/simplex scatter plot with barycentric coordinate system and equilateral triangle geometry. Auto-normalize withwith_normalize(true), configurable grid lines (dashed), percentage tick labels on each edge, bold corner labels, and multi-group coloring. CLI:kuva ternary --a <COL> --b <COL> --c <COL> [--color-by <COL>] [--a-label <S>] [--b-label <S>] [--c-label <S>] [--normalize] [--grid-lines <N>]. Closes #8.RidgelinePlot— ridgeline (joyplot) plot with stacked KDE density curves, one per group. Groups are labelled on the y-axis; the x-axis is the continuous data range. Supports.with_group(label, data),.with_group_color(label, data, color),.with_groups(iter),.with_filled(bool),.with_opacity(f64),.with_overlap(f64),.with_bandwidth(f64),.with_kde_samples(usize),.with_stroke_width(f64),.with_normalize(bool),.with_legend(bool), and.with_line_dash(s). CLI:kuva ridgeline --value <COL> [--group-by <COL>] [--overlap <F>] [--filled] [--bandwidth <F>].DensityPlot— kernel density estimate curve over a single numeric column. Gaussian KDE via Silverman's rule (or manual bandwidth), normalised to a proper probability density function (integral ≈ 1). Supports.with_filled(bool),.with_opacity(f64),.with_bandwidth(f64),.with_kde_samples(usize),.with_stroke_width(f64),.with_line_dash(s),.with_legend(s), andfrom_curve(x, y)for pre-computed curves. Multi-group plots use oneDensityPlotper group withrender_multiple+ palette. CLI:kuva density --value <COL> [--color-by <COL>] [--filled] [--bandwidth <F>]. Closes #15.Histogram::from_bins(edges, counts)— create a histogram from precomputed bin edges and counts rather than raw values.edgesmust have lengthcounts.len() + 1; counts aref64to support fractional values (density estimates, normalised outputs from R/numpy). Closes #24.LegendPositionexpanded — the 7 old variants are replaced by 20 new ones grouped by placement zone. All names are now prefixed withInsideorOutside:- Inside (overlaid on the data area, 8 px inset):
InsideTopRight,InsideTopLeft,InsideBottomRight,InsideBottomLeft,InsideTopCenter,InsideBottomCenter - Outside right margin:
OutsideRightTop(new default),OutsideRightMiddle,OutsideRightBottom - Outside left margin:
OutsideLeftTop,OutsideLeftMiddle,OutsideLeftBottom - Outside top margin:
OutsideTopLeft,OutsideTopCenter,OutsideTopRight - Outside bottom margin:
OutsideBottomLeft,OutsideBottomCenter,OutsideBottomRight Custom(f64, f64)— absolute SVG canvas pixel coordinates (whatwith_legend_atnow sets internally)DataCoords(f64, f64)— data-space coordinates mapped throughmap_x/map_yat render time
- Inside (overlaid on the data area, 8 px inset):
Layout::with_legend_box(bool)— suppress the legend background and border rects; entries and swatches still renderLayout::with_legend_title(s)— renders a bold title row above all legend entriesLayout::with_legend_group(title, entries)— adds a labelled group of entries; multiple calls stack and take priority overwith_legend_entriesLayout::with_legend_at_data(x, y)— places the legend at data-space coordinates (DataCoordsvariant); no right-margin reservedLegendGroupstruct —{ title: String, entries: Vec<LegendEntry> }; exported fromkuva::plotLayout::with_legend_width(px)/with_legend_height(px)— override auto-computed legend box dimensionsLayout::with_scale(f)— uniform scale factor for all plot chrome: font sizes, margins, tick mark lengths, stroke widths, legend padding/swatch geometry, and annotation arrow sizes. Canvaswidth/heightare unaffected. CLI:--scaleon all subcommands.- Fine-grained tick and gridline control (#13) —
Layout::with_x_axis_min/max,with_y_axis_min/max,with_x_tick_step,with_y_tick_step,with_minor_ticks(n),with_show_minor_grid(bool); minor ticks are 3 px marks; minor gridlines use 0.5 stroke-width. CLI:--x-min,--x-max,--y-min,--y-max,--x-tick-step,--y-tick-step,--minor-ticks,--minor-grid. - Per-point colors on
ScatterPlotand per-group colors onStripPlot—ScatterPlot::with_colors(iter)indexed per point;StripPlot::with_group_colors(iter)indexed per group. Both fall back to the uniformcolorfield for out-of-range indices.ScatterPlot::bounds()now returnsNoneon empty data rather than panicking. - Per-group colors on
ViolinPlotandBoxPlot—with_group_colors(iter)added to both, mirroringStripPlot. All elements of a box group (box, whiskers, caps) share the group color. CLI:--group-colors(comma-separated) onkuva violinandkuva box. - Circle marker opacity + stroke —
Primitive::CircleandPrimitive::CircleBatchnow carryfill_opacity: Option<f64>,stroke: Option<Color>, andstroke_width: Option<f64>. Builder methodswith_marker_opacity(f64)andwith_marker_stroke_width(f64)added toScatterPlot,StripPlot,PolarPlot(per-series), andTernaryPlot. Colortype (render::color) — 3-variant enum (Rgb/None/Css) replacingStringfor fill/stroke in the render pipeline;Color::Rgb(u8,u8,u8)is 4 bytes inline with zero heap allocation;From<&str>parses hex,rgb(),"none", and 50+ named CSS colors.CircleBatchandRectBatch— SoA (struct-of-arrays)Primitivevariants with contiguous coordinate arrays for scatter and heatmap; all backends support them.- Benchmark suite —
benches/render.rs,benches/svg.rs,benches/kde.rswith Criterion;docs/src/benchmarks.mdwith tables and run instructions.
Changed
Layout::with_legend_at(x, y)now setslegend_position = Custom(x, y);legend_xyfield removed- Margin calculation in
ComputedLayout::from_layoutis position-aware:Inside*,Custom, andDataCoordsadd no margin;Outside*variants expand the appropriate edge render_legend_atsignature extended withgroups,title, andshow_boxparameters- Legend width auto-sizing character multiplier increased from 7.0 → 8.5 px/char
Primitive::Pathnow usesBox<PathData>— shrinks enum from ~128 to ~88 bytes per element- SVG output uses hex colors for named CSS colors (e.g.
fill="red"→fill="#ff0000") - SVG serialization 50–70% faster — replaced all
format!()calls inSvgBackendwith directpush_str()/write!(); eliminates per-primitive heap allocations in hot loops - Float formatting via
ryu— 2–5× faster float→string conversion; coordinates rounded to 2 decimal places; whole numbers omit the decimal point - Single-pass XML escaping —
write_escaped()scans text content once; no allocation when input has no special characters PngBackendfont database cached — system fonts loaded once viaOnceLock; eliminates 100ms+ overhead on repeated PNG rendersScenepre-allocated —Scene::new()accepts an estimated primitive count and callsVec::with_capacity()- KDE truncated kernel —
simple_kdewindows evaluations to[x ± 4bw]via binary search; ~8× faster at 100k samples - Manhattan pre-bucketing — SNPs bucketed into
HashMap<&str, Vec<usize>>before span loop; ~22× faster at 1M SNPs - Heatmap single-pass — two nested loops merged into one; intermediate
flat: Vec<f64>allocation eliminated
Fixed
render_twin_ynow supportsPlot::Density—DensityPlotwas silently dropped in both the primary and secondary match arms; it is now routed toadd_densitywith the correct computed layout for each axis.- Legend overhaul — background/border rects can now be suppressed via
with_legend_box(false); y-axis label x-position computed dynamically from actual tick label widths rather than a fixed offset;margin_leftnow uses actual tick string generation instead of a 6-char heuristic BrickPlotstrigar color/legend ordering — deterministic sort replacesHashMapiteration order; output is now byte-identical across runs- Rotated x-axis tick labels —
margin_left/margin_rightnow account for horizontal projection of rotated labels;TextAnchor::Startused for positive rotation angles. Affects bar, waterfall, candlestick, and dot plots. - Terminal legend swatch alignment —
LegendShape::Lineswatches now write tochar_gridso they take priority over legend background;LegendShape::Rectsnaps toheight × 0.75so swatches land in the same row as their label at all terminal sizes - Terminal legend entry spacing — legend entries step by exact whole-cell multiples (
round(18 / cell_h).max(1) * cell_h); eliminates fractional-row misalignment across all terminal sizes and subcommands - Terminal phylo leaf label row — removed
+ 4.0SVG baseline offset on leaf labels for Left/Right orientations ridgelineexample — output now written todocs/src/assets/ridgeline/instead of the repo root
pull requests
- Performance improvement for SVG indentation. by @emilbratt in #22
- perf: rewrite hot paths to eliminate allocations and use fast formatting - 30-70% faster SVG rendering by @jrmoynihan in #29
- perf: compact Color type, boxed Path, SoA batches, rayon parallelism by @jrmoynihan in #30
- dev candidate for v0.1.4 by @Psy-Fer in #34
- Add twin Y docs by @Psy-Fer in #35
New Contributors
- @jrmoynihan made their first contribution in #29
Full Changelog: v0.1.3...v0.1.4