Crate plt

source ·
Expand description

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::Canvas.

Use

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

Example

// 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();

Dependencies

Currently, the only implemented backend depends on Cairo.

Debian / Ubuntu

apt install libcairo2-dev

Arch

pacman -Syu cairo

Modules

Re-exports of neccessary plt-draw backend elements.

Structs

An RGBA float representation of a color.
The size of a figure, in inches.
Represents a whole figure, containing subplots, which can be drawn as an image.
Describes the configuration of a Figure.
Fills a region of a subplot with a color.
Defines an area of a figure in terms of fractional boundaries.
A Layout in which subplots are placed in a grid orientation in the figure.
Plots data on a subplot using the builder pattern.
A Layout in which a single subplot fills the whole figure.
The object that represents a whole subplot and is used to draw plotted data.
Builds and sets the configuration for a Subplot.
The formatting for a subplot.

Enums

Identifies one or more plot axes.
A graphics image file format.
The name of a text font.
Indicates which, if any, tick marks on an axis should have grid lines.
How the maximum and minimum plotted values of an axis should be set.
Plotting line styles.
Marker shapes.
The error type for this library.
Indicates which side of the axes ticks should point towards.
Describes how and whether tick mark labels are set.
Describes how tick mark locations are determined, if at all.

Traits

Defines how and where Subplots are place in a Figure.