Skip to main content

Crate kuva

Crate kuva 

Source
Expand description

Scientific plotting library for bioinformatics, targeting SVG output with optional PNG and PDF backends.

§Pipeline

plot definition  →  Layout  →  Scene (primitives)  →  backend output
  1. Build a plot struct using its builder API (e.g. plot::scatter::ScatterPlot).
  2. Collect plots into a Vec<render::plots::Plot> — use .into() on any plot struct.
  3. Build a render::layout::Layout with render::layout::Layout::auto_from_plots and customise it.
  4. Call render_to_svg (or render_to_png / render_to_pdf) to get the output in one step.

§Example

use kuva::prelude::*;

let scatter = ScatterPlot::new()
    .with_data(vec![(1.0_f64, 2.0), (3.0, 4.0)])
    .with_color("steelblue");

let plots: Vec<Plot> = vec![scatter.into()];
let svg = kuva::render_to_svg(plots, Layout::auto_from_plots(&[]));
assert!(svg.contains("<svg"));

§Feature flags

FeatureDescription
pngEnables PngBackend for rasterising SVG scenes via resvg.
pdfEnables PdfBackend for vector PDF output via svg2pdf.
cliEnables the kuva CLI binary (pulls in clap).
fullEnables png + pdf.

Re-exports§

pub use backend::terminal::TerminalBackend;
pub use backend::png::PngBackend;
pub use backend::raster::RasterBackend;
pub use backend::pdf::PdfBackend;
pub use render::theme::Theme;
pub use render::palette::Palette;
pub use render::layout::TickFormat;
pub use render::render::render_twin_y;
pub use render::render::render_sankey;
pub use render::render::render_phylo_tree;
pub use render::render::render_synteny;
pub use render::datetime::DateTimeAxis;
pub use render::datetime::DateUnit;
pub use render::datetime::ymd;
pub use render::datetime::ymd_hms;

Modules§

backend
plot
prelude
Convenience re-exports for the most commonly used types.
render

Functions§

render_to_pdf
Render a collection of plots to a PDF byte vector in one call (requires feature pdf).
render_to_png
Render a collection of plots to a PNG byte vector in one call (requires feature png).
render_to_raster
Render a collection of plots directly to a PNG byte vector via tiny_skia, bypassing SVG serialization and re-parsing (requires feature png).
render_to_svg
Render a collection of plots to an SVG string in one call.