MCPcopy Create free account
hub / github.com/4bb4/implot-rs / show_basic_vertical_plot

Function show_basic_vertical_plot

implot-examples/examples-shared/src/bar_plots.rs:7–22  ·  view source on GitHub ↗
(ui: &Ui, plot_ui: &PlotUi)

Source from the content-addressed store, hash-verified

5use implot::{Plot, PlotBars, PlotUi};
6
7pub fn show_basic_vertical_plot(ui: &Ui, plot_ui: &PlotUi) {
8 ui.text(im_str!("This header shows a simple vertical bar plot."));
9 let content_width = ui.window_content_region_width();
10 Plot::new("Vertical bar plot")
11 // The size call could also be omitted, though the defaults don't consider window
12 // width, which is why we're not doing so here.
13 .size([content_width, 300.0])
14 .build(plot_ui, || {
15 // If this is called outside a plot build callback, the program will panic.
16 let axis_positions = vec![0.2, 0.4, 0.6, 0.8];
17 let values = vec![0.1, 0.2, 0.3, 0.4];
18 PlotBars::new("legend label")
19 .with_bar_width(0.1)
20 .plot(&axis_positions, &values);
21 });
22}
23
24pub fn show_basic_horizontal_plot(ui: &Ui, plot_ui: &PlotUi) {
25 ui.text(im_str!("This header shows a simple horizontal bar plot."));

Callers 1

show_demo_headersFunction · 0.85

Calls 4

buildMethod · 0.80
sizeMethod · 0.80
plotMethod · 0.80
with_bar_widthMethod · 0.80

Tested by

no test coverage detected