Module sb_rust_library::plotter[][src]

Tiny library used to plot data through graphical primitives.

The main object it provides is Plot which enables plotting data using basic primitives like circles, line segments, and oriented points. You can plot data using any of the shapes provided in shapes through the corresponding draw methods.

Examples

Basic sine wave without axis labels

let mut p = Plot::new(300, 200)
  .with_canvas_color(GREY)
  .with_bg_color(BLUE)
  .with_plotting_range(0.0..(2.0 * PI), -1.1..1.1)
  .with_drawing_bounds(0.05..0.95, 0.1..0.95);

let x_values: Vec<f64> = (0..1000).map(|i| (i as f64) / 1000.0 * 2.0 * PI).collect();
let points: Vec<Point> = x_values.into_iter().map(|x| {
  (x, x.sin()).into()
}).collect();

let circle = Circle::new(RED, 1);
p.draw_circles(&circle, &points);
p.save("sine-wave.bmp").unwrap();

Structs

Circle

Circle shape used to plot data.

Orientation

Oriented point with fixed with and variable angle used to plot data.

Plot

Struct used to plot data and generate images.

Constants

BLACK

A nice looking black.

BLUE

A nice looking blue.

GREEN

A nice looking green.

GREY

A nice looking greyish.

MAUVE

A nice looking mauve.

ORANGE

A nice looking orange.

PINK

A nice looking pinkish.

PURPLE

A nice looking purple.

RED

A nice looking red.

WHITE

A nice looking white.

YELLOW

A nice looking yellow.

Type Definitions

Color

A 32-bit color used for plotting.