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

Function test_barplot_4

tests/test_barplot.rs:111–139  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

109
110#[test]
111fn test_barplot_4() -> Result<(), StrError> {
112 // data
113 let fruits = ["Apple", "Banana", "Orange"];
114 let prices = [10.0, 20.0, 30.0];
115 let errors = [3.0, 2.0, 1.0];
116
117 // barplot object and options
118 let mut bar = Barplot::new();
119 bar.set_errors(&errors)
120 .set_horizontal(true)
121 .set_with_text("edge")
122 .draw_with_str(&fruits, &prices);
123
124 // plot
125 let mut plot = Plot::new();
126 plot.set_inv_y().add(&bar);
127
128 // save figure
129 let path = Path::new(OUT_DIR).join("integ_barplot_4.svg");
130 plot.set_title("Fruits").set_label_x("price").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 > 770 && c < 810);
138 Ok(())
139}
140
141#[test]
142fn test_barplot_5() -> Result<(), StrError> {

Callers

nothing calls this directly

Calls 9

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

Tested by

no test coverage detected