malevich 0.7.0

Terminal plotting: a small grammar of marks, honest axes, millions of points
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
//! Annotations: a Rule for the target line, a Text note at data coordinates —
//! both extend the axis domains so they are never silently off-plot.

use malevich::{Frame, Line, Plot, Rule, Text};

fn main() {
    let loss: Vec<f64> = (0..70)
        .map(|i| 4.0 * (-0.06 * i as f64).exp() + 0.4)
        .collect();
    let plot = Plot::new()
        .layer(Line::y(&loss[..]).label("loss"))
        .layer(Rule::h(0.5).label("target"))
        .layer(Text::at(34.0, 2.2, "< converging"))
        .title("annotated loss (synthetic)");
    println!("{}", plot.render(&Frame::plain(60, 14)));
}