plt

Crates.ioplt
lib.rsplt
version0.4.1
sourcesrc
created_at2022-08-25 00:31:21.528549
updated_at2022-11-18 17:26:12.201164
descriptionPlotting library with a focus on publication level aesthetics and ergonomic control.
homepage
repositoryhttps://github.com/plt-rs/plt
max_upload_size
id651848
size359,110
Jonah Hoffman (jonah-h)

documentation

README

plt

CI Crates.io docs.rs dependency status

A plotting library with a focus on publication level aesthetics and ergonomic control.

Structure

  • Plots are drawn on a Subplot.
  • One or more subplots are organized in a Layout.
  • The layout is added to a Figure, which is used to draw to a file or directly to a Backend.

Use

To get started, see the examples directory in the main repository.

Example

use plt::*;

// create data
let xs: Vec<f64> = (0..=100).map(|n: u32| n as f64 * 0.1).collect();
let ys: Vec<f64> = xs.iter().map(|x| x.powi(3)).collect();

// create subplot
let mut sp = Subplot::builder()
    .label(Axes::X, "x data")
    .label(Axes::Y, "y data")
    .build();

// plot data
sp.plot(&xs, &ys).unwrap();

// make figure and add subplot
let mut fig = <Figure>::default();
fig.set_layout(SingleLayout::new(sp)).unwrap();

// save figure to file
fig.draw_file(FileFormat::Png, "example.png").unwrap();

Simple Example

Dependencies

Currently, the only implemented backend depends on Cairo.

Debian / Ubuntu

apt install libcairo2-dev

Arch

pacman -Syu cairo

Commit count: 101

cargo fmt