(&self, ui: &mut egui::Ui)
| 22 | } |
| 23 | |
| 24 | pub fn show_plot(&self, ui: &mut egui::Ui) -> Response { |
| 25 | let yellow = egui::Color32::from_rgb(248, 252, 168); |
| 26 | let mut box1 = BoxPlot::new( |
| 27 | "Experiment A", |
| 28 | vec![ |
| 29 | BoxElem::new(0.5, BoxSpread::new(1.5, 2.2, 2.5, 2.6, 3.1)).name("Day 1"), |
| 30 | BoxElem::new(2.5, BoxSpread::new(0.4, 1.0, 1.1, 1.4, 2.1)).name("Day 2"), |
| 31 | BoxElem::new(4.5, BoxSpread::new(1.7, 2.0, 2.2, 2.5, 2.9)).name("Day 3"), |
| 32 | ], |
| 33 | ); |
| 34 | |
| 35 | let mut box2 = BoxPlot::new( |
| 36 | "Experiment B", |
| 37 | vec![ |
| 38 | BoxElem::new(1.0, BoxSpread::new(0.2, 0.5, 1.0, 2.0, 2.7)).name("Day 1"), |
| 39 | BoxElem::new(3.0, BoxSpread::new(1.5, 1.7, 2.1, 2.9, 3.3)) |
| 40 | .name("Day 2: interesting") |
| 41 | .stroke(egui::Stroke::new(1.5, yellow)) |
| 42 | .fill(yellow.linear_multiply(0.2)), |
| 43 | BoxElem::new(5.0, BoxSpread::new(1.3, 2.0, 2.3, 2.9, 4.0)).name("Day 3"), |
| 44 | ], |
| 45 | ); |
| 46 | |
| 47 | let mut box3 = BoxPlot::new( |
| 48 | "Experiment C", |
| 49 | vec![ |
| 50 | BoxElem::new(1.5, BoxSpread::new(2.1, 2.2, 2.6, 2.8, 3.0)).name("Day 1"), |
| 51 | BoxElem::new(3.5, BoxSpread::new(1.3, 1.5, 1.9, 2.2, 2.4)).name("Day 2"), |
| 52 | BoxElem::new(5.5, BoxSpread::new(0.2, 0.4, 1.0, 1.3, 1.5)).name("Day 3"), |
| 53 | ], |
| 54 | ); |
| 55 | |
| 56 | if self.horizontal { |
| 57 | box1 = box1.horizontal(); |
| 58 | box2 = box2.horizontal(); |
| 59 | box3 = box3.horizontal(); |
| 60 | } |
| 61 | |
| 62 | Plot::new("Box Plot Demo") |
| 63 | .legend(Legend::default()) |
| 64 | .allow_zoom(egui::Vec2b::new(false, false)) |
| 65 | .allow_drag(egui::Vec2b::new(false, false)) |
| 66 | .allow_scroll(egui::Vec2b::new(false, false)) |
| 67 | .show(ui, |plot_ui| { |
| 68 | plot_ui.box_plot(box1); |
| 69 | plot_ui.box_plot(box2); |
| 70 | plot_ui.box_plot(box3); |
| 71 | }) |
| 72 | .response |
| 73 | } |
| 74 | } |
no test coverage detected