MCPcopy Create free account
hub / github.com/emilk/egui_plot / show_plot

Method show_plot

examples/histogram/src/app.rs:28–52  ·  view source on GitHub ↗
(&self, ui: &mut egui::Ui)

Source from the content-addressed store, hash-verified

26 }
27
28 pub fn show_plot(&self, ui: &mut egui::Ui) -> Response {
29 let mut chart = BarChart::new(
30 "Normal Distribution",
31 (-395..=395)
32 .step_by(10)
33 .map(|x| x as f64 * 0.01)
34 .map(|x| (x, (-x * x / 2.0).exp() / (2.0 * std::f64::consts::PI).sqrt()))
35 .map(|(x, f)| Bar::new(x, f * 10.0).width(0.1))
36 .collect(),
37 )
38 .color(egui::Color32::LIGHT_BLUE);
39
40 if !self.vertical {
41 chart = chart.horizontal();
42 }
43
44 Plot::new("Normal Distribution Demo")
45 .legend(Legend::default())
46 .clamp_grid(true)
47 .allow_zoom(egui::Vec2b::new(true, true))
48 .allow_drag(egui::Vec2b::new(true, true))
49 .allow_scroll(egui::Vec2b::new(true, true))
50 .show(ui, |plot_ui| plot_ui.bar_chart(chart))
51 .response
52 }
53}

Callers 1

show_uiMethod · 0.45

Calls 10

showMethod · 0.80
allow_scrollMethod · 0.80
allow_dragMethod · 0.80
allow_zoomMethod · 0.80
clamp_gridMethod · 0.80
legendMethod · 0.80
bar_chartMethod · 0.80
colorMethod · 0.45
widthMethod · 0.45
horizontalMethod · 0.45

Tested by

no test coverage detected