File: function_svg.rs

package info (click to toggle)
rust-plotlib 0.5.1-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 628 kB
  • sloc: sh: 19; makefile: 4
file content (17 lines) | stat: -rw-r--r-- 626 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use plotlib::page::Page;
use plotlib::repr::Plot;
use plotlib::style::LineStyle;
use plotlib::view::ContinuousView;

fn main() {
    let f1 =
        Plot::from_function(|x| x * 5., 0., 10.).line_style(LineStyle::new().colour("burlywood"));
    let f2 = Plot::from_function(|x| x.powi(2), 0., 10.)
        .line_style(LineStyle::new().colour("darkolivegreen").width(2.));
    let f3 = Plot::from_function(|x| x.sqrt() * 20., 0., 10.)
        .line_style(LineStyle::new().colour("brown").width(1.));

    let v = ContinuousView::new().add(f1).add(f2).add(f3);

    Page::single(&v).save("function.svg").expect("saving svg");
}