general_2d_plot/
general_2d_plot.rs1use plotting::{Color, Figure, Format, FormatBuilder, LineStyle, NamedColor, Trace};
2use std::path::Path;
3
4fn main() {
5 let trace_1 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 2.0, 3.0])
7 .name("y = x")
8 .line_color(Color::named(NamedColor::Red))
9 .line_width(2.0)
10 .line_style(LineStyle::Dash);
11 let trace_2 = Trace::new_2d([1.0, 2.0, 3.0], [1.0, 4.0, 9.0])
12 .name("y = x^2")
13 .line_color(Color::named(NamedColor::Blue))
14 .line_width(2.0)
15 .line_style(LineStyle::Dot);
16
17 let format: Format = FormatBuilder::default()
19 .title("y vs. x")
20 .x_label("x")
21 .y_label("y")
22 .width(800)
23 .height(600)
24 .build()
25 .unwrap();
26
27 let fig = Figure::new(vec![trace_1, trace_2], format);
29
30 fig.save_inline_html(Path::new("book/src/figures/general_2d_plot.html"));
32
33 }