MCPcopy Index your code
hub / github.com/cpmech/plotpy / test_boxplot_1

Function test_boxplot_1

tests/test_boxplot.rs:9–53  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

7
8#[test]
9fn test_boxplot_1() -> Result<(), StrError> {
10 let data = vec![
11 // A B C D E
12 vec![1, 2, 3, 4, 5],
13 vec![2, 3, 4, 5, 6],
14 vec![3, 4, 5, 6, 7],
15 vec![4, 5, 6, 7, 8],
16 vec![5, 6, 7, 8, 9],
17 vec![6, 7, 8, 9, 10],
18 vec![15, 15, 15, 15, 15], // fliers
19 ];
20
21 let positions = [2.0, 2.5, 3.0, 3.5, 4.0];
22 let labels = ["A", "B", "C", "D", "E"];
23
24 // boxplot object and options
25 let mut boxes = Boxplot::new();
26 boxes
27 .set_symbol("b.")
28 .set_horizontal(true)
29 .set_positions(&positions)
30 .set_width(0.45)
31 .set_whisker(2.0)
32 .set_no_fliers(false)
33 .set_extra("notch=True")
34 .draw_mat(&data);
35
36 let mut plot = Plot::new();
37 plot.add(&boxes)
38 .set_inv_y()
39 .set_title("boxplot integration test")
40 .set_ticks_y_labels(&positions, &labels);
41
42 // save figure
43 let path = Path::new(OUT_DIR).join("integ_boxplot_1.svg");
44 plot.save(&path)?;
45
46 // check number of lines
47 let file = File::open(path).map_err(|_| "cannot open file")?;
48 let buffered = BufReader::new(file);
49 let lines_iter = buffered.lines();
50 let c = lines_iter.count();
51 assert!(c > 1000 && c < 1100);
52 Ok(())
53}
54
55#[test]
56fn test_boxplot_2() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 13

draw_matMethod · 0.80
set_no_fliersMethod · 0.80
set_whiskerMethod · 0.80
set_positionsMethod · 0.80
set_symbolMethod · 0.80
set_ticks_y_labelsMethod · 0.80
set_inv_yMethod · 0.80
saveMethod · 0.80
set_extraMethod · 0.45
set_widthMethod · 0.45
set_horizontalMethod · 0.45
set_titleMethod · 0.45

Tested by

no test coverage detected