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

Function test_barplot_5

tests/test_barplot.rs:142–170  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

140
141#[test]
142fn test_barplot_5() -> Result<(), StrError> {
143 // data
144 let y = vec![-2.5, -15.0, -5.0, -7.5, -2.5, -5.0, -17.5];
145 let e = vec![0.5, 0.4, 0.1, 0.7, 0.2, 0.0, 1.7];
146 let _x: Vec<f64> = (0..y.len()).map(|a| a as f64).collect();
147 let _x_str = vec!["Uno", "Dos", "Tres", "Cuatro", "Cinco", "Seis", "Siete"];
148
149 // barplot
150 let mut bar = Barplot::new();
151 bar.set_errors(&e)
152 // .draw(&_x, &y); // requires numbers, as expected
153 .draw_with_str(&_x_str, &y); // requires string, as expected
154
155 // plot
156 let mut plot = Plot::new();
157 plot.add(&bar);
158
159 // save figure
160 let path = Path::new(OUT_DIR).join("integ_barplot_5.svg");
161 plot.save(&path)?;
162
163 // check number of lines
164 let file = File::open(path).map_err(|_| "cannot open file")?;
165 let buffered = BufReader::new(file);
166 let lines_iter = buffered.lines();
167 let c = lines_iter.count();
168 assert!(c > 830 && c < 900);
169 Ok(())
170}

Callers

nothing calls this directly

Calls 4

draw_with_strMethod · 0.80
set_errorsMethod · 0.80
saveMethod · 0.80
addMethod · 0.45

Tested by

no test coverage detected