Skip to main content

scatterplot

Function scatterplot 

Source
pub fn scatterplot<X: ToString, Y: ToString>(
    x: &[X],
    y: &[Y],
    options: LineplotOptions,
) -> Result<Plot<GridCanvas>, LineplotError>
Expand description

Constructs a scatterplot from explicit x/y values.

§Examples

use unicode_plot::{scatterplot, LineplotOptions};

let x = vec![1.0, 2.5, 3.0, 4.5, 5.0];
let y = vec![2.0, 1.5, 4.0, 3.5, 5.0];
let plot = scatterplot(&x, &y, LineplotOptions::default()).unwrap();

let mut buf = Vec::new();
plot.render(&mut buf, false).unwrap();
assert!(!buf.is_empty());

§Errors

Returns LineplotError::LengthMismatch when lengths differ, LineplotError::EmptySeries for empty input, and LineplotError::InvalidNumericValue when parsing fails.