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

Function test_boxplot_3

tests/test_boxplot.rs:97–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

95
96#[test]
97fn test_boxplot_3() -> Result<(), StrError> {
98 let data = vec![
99 // A B C D E ← matrix: columns are series
100 // nested: rows are series
101 // ↓
102 vec![1.0, 2.0, 3.0, 4.0, 5.0], // A
103 vec![1.1, 2.1, 3.1, 4.1, 5.1], // B
104 vec![1.2, 2.2, 3.2, 4.2, 5.2], // C
105 vec![1.3, 2.3, 3.3, 4.3, 5.3], // D
106 vec![1.4, 2.4, 3.4, 4.4, 5.4], // E
107 ];
108
109 let ticks = [1, 2, 3, 4, 5];
110 let labels = ["A", "B", "C", "D", "E"];
111
112 let mut boxes_nes = Boxplot::new();
113 boxes_nes.draw(&data);
114
115 let mut boxes_mat = Boxplot::new();
116 boxes_mat.draw_mat(&data);
117
118 let mut plot = Plot::new();
119 plot.set_subplot(1, 2, 1)
120 .set_title("nested")
121 .add(&boxes_nes)
122 .set_ticks_x_labels(&ticks, &labels)
123 .set_subplot(1, 2, 2)
124 .set_title("matrix")
125 .add(&boxes_mat)
126 .set_ticks_x_labels(&ticks, &labels);
127
128 // save figure
129 let path = Path::new(OUT_DIR).join("integ_boxplot_3.svg");
130 plot.set_figure_size_points(650.0, 300.0).save(&path)?;
131
132 // check number of lines
133 let file = File::open(path).map_err(|_| "cannot open file")?;
134 let buffered = BufReader::new(file);
135 let lines_iter = buffered.lines();
136 let c = lines_iter.count();
137 assert!(c > 1180 && c < 1260);
138 Ok(())
139}
140
141#[test]
142fn test_boxplot_4() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 8

draw_matMethod · 0.80
set_ticks_x_labelsMethod · 0.80
set_subplotMethod · 0.80
saveMethod · 0.80
drawMethod · 0.45
addMethod · 0.45
set_titleMethod · 0.45

Tested by

no test coverage detected