Skip to main content

Installation Methods

Kuva can be installed as a Rust library (for use in your code) or as a standalone CLI binary (for command-line plotting). Both methods support optional PNG and PDF backends.

Library Installation

1

Add Kuva to Cargo.toml

Add the dependency to your Cargo.toml file:
[dependencies]
kuva = "0.1"
The default installation includes only SVG output. Enable optional features for PNG (via resvg) or PDF (via svg2pdf) support.
2

Import the prelude

Import all commonly used types with a single line:
use kuva::prelude::*;
This brings into scope:
  • All 25 plot structs (ScatterPlot, LinePlot, VolcanoPlot, etc.)
  • The Plot enum
  • Layout and Figure for composition
  • Theme and Palette for styling
  • Render functions (render_to_svg, render_to_png, render_to_pdf)
  • Backend types (SvgBackend, PngBackend, PdfBackend, TerminalBackend)
3

Verify installation

Create a simple test program to verify the installation:
use kuva::prelude::*;

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

    let plots: Vec<Plot> = vec![plot.into()];
    let layout = Layout::auto_from_plots(&plots);
    
    let svg = render_to_svg(plots, layout);
    println!("Generated {} bytes of SVG", svg.len());
}
Run with cargo run. You should see output confirming SVG generation.

CLI Installation

The CLI binary provides command-line access to all plot types without writing Rust code.
1

Install from crates.io

cargo install kuva --features cli
This installs the kuva binary to ~/.cargo/bin/ (ensure it’s in your PATH).
Installation may take several minutes as dependencies are compiled. The full feature requires additional system libraries for PDF/PNG rendering.
2

Install from source

Clone the repository and build locally:
git clone https://github.com/Psy-Fer/kuva.git
cd kuva
cargo build --release --bin kuva --features cli
The binary will be at target/release/kuva. Copy it to a location in your PATH.
3

Verify CLI installation

Check that the CLI is installed and accessible:
kuva --version
List available plot types:
kuva --help
You should see all 25 subcommands listed (scatter, line, bar, volcano, manhattan, etc.).

Feature Flags Reference

Kuva uses Cargo feature flags to control optional functionality:
FeatureDescriptionDependencies
(default)SVG output onlyNone (uses built-in SVG renderer)
pngEnable PNG rasterization via resvgresvg = "0.44"
pdfEnable PDF vector output via svg2pdfsvg2pdf = "0.13"
cliBuild the kuva CLI binaryclap = "4", clap_mangen = "0.2"
fullEnable both PNG and PDF (png + pdf)All of the above

System Requirements

Minimum Rust Version

Kuva requires Rust 2021 edition or later. The MSRV (Minimum Supported Rust Version) is currently 1.70.0.

Platform Support

Kuva is tested on:
  • Linux — Ubuntu 20.04+, Debian 11+, Fedora 35+
  • macOS — macOS 11+ (Intel and Apple Silicon)
  • Windows — Windows 10+ (x86_64)

Optional Dependencies

If using the png feature, ensure you have:
  • Standard C/C++ compiler toolchain
  • System libraries that resvg depends on (typically already present)
If using the pdf feature:
  • No additional system dependencies required

Troubleshooting

This typically happens with the png feature on systems missing development libraries.On Ubuntu/Debian:
sudo apt-get install build-essential pkg-config
On Fedora/RHEL:
sudo dnf install gcc gcc-c++ pkg-config
On macOS:
xcode-select --install
Ensure ~/.cargo/bin is in your PATH:
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.bashrc
source ~/.bashrc
Or for zsh:
echo 'export PATH="$HOME/.cargo/bin:$PATH"' >> ~/.zshrc
source ~/.zshrc
Enable parallel compilation and increase optimization:
# Use more CPU cores
export CARGO_BUILD_JOBS=8

# Or install with cargo-binstall for pre-compiled binaries
cargo install cargo-binstall
cargo binstall kuva --features cli,full
If you see dependency resolution errors, try:
cargo update
cargo clean
cargo build
Or pin specific dependency versions in your Cargo.toml.

Next Steps

Quick Start

Create your first plot in minutes

API Reference

Explore the full API documentation

Build docs developers (and LLMs) love