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§

backend
Re-exports of neccessary plt-draw backend elements.

Structs§

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

Enums§

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

Traits§

Layout
Defines how and where Subplots are place in a Figure.