MCPcopy Create free account
hub / github.com/cpmech/plotpy / test_barplot_3

Function test_barplot_3

tests/test_barplot.rs:80–108  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

78
79#[test]
80fn test_barplot_3() -> Result<(), StrError> {
81 // data
82 let fruits = [1.0, 2.0, 3.0];
83 let prices = [10.0, 20.0, 30.0];
84 let errors = [3.0, 2.0, 1.0];
85
86 // barplot object and options
87 let mut bar = Barplot::new();
88 bar.set_errors(&errors)
89 .set_horizontal(true)
90 .set_with_text("edge")
91 .draw(&fruits, &prices);
92
93 // plot
94 let mut plot = Plot::new();
95 plot.set_inv_y().add(&bar);
96
97 // save figure
98 let path = Path::new(OUT_DIR).join("integ_barplot_3.svg");
99 plot.set_title("Fruits").set_label_x("price").save(&path)?;
100
101 // check number of lines
102 let file = File::open(path).map_err(|_| "cannot open file")?;
103 let buffered = BufReader::new(file);
104 let lines_iter = buffered.lines();
105 let c = lines_iter.count();
106 assert!(c > 660 && c < 700);
107 Ok(())
108}
109
110#[test]
111fn test_barplot_4() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 9

set_with_textMethod · 0.80
set_errorsMethod · 0.80
set_inv_yMethod · 0.80
saveMethod · 0.80
set_label_xMethod · 0.80
drawMethod · 0.45
set_horizontalMethod · 0.45
addMethod · 0.45
set_titleMethod · 0.45

Tested by

no test coverage detected