MCPcopy Create free account
hub / github.com/alceal/plotlars / main

Function main

crates/plotlars/examples/plotly_histogram.rs:4–39  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

2use plotlars::{Axis, CsvReader, Histogram, Legend, Plot, Rgb, Text, TickDirection};
3
4fn main() {
5 let dataset = CsvReader::new("data/penguins.csv")
6 .finish()
7 .unwrap()
8 .lazy()
9 .select([
10 col("species"),
11 col("sex").alias("gender"),
12 col("flipper_length_mm").cast(DataType::Int16),
13 col("body_mass_g").cast(DataType::Int16),
14 ])
15 .collect()
16 .unwrap();
17
18 let axis = Axis::new()
19 .show_line(true)
20 .show_grid(true)
21 .value_thousands(true)
22 .tick_direction(TickDirection::OutSide);
23
24 Histogram::builder()
25 .data(&dataset)
26 .x("body_mass_g")
27 .group("species")
28 .opacity(0.5)
29 .colors(vec![Rgb(255, 165, 0), Rgb(147, 112, 219), Rgb(46, 139, 87)])
30 .plot_title(Text::from("Histogram").font("Arial").size(18))
31 .x_title(Text::from("body mass (g)").font("Arial").size(15))
32 .y_title(Text::from("count").font("Arial").size(15))
33 .legend_title(Text::from("species").font("Arial").size(15))
34 .x_axis(&axis)
35 .y_axis(&axis)
36 .legend(&Legend::new().x(0.9))
37 .build()
38 .plot();
39}

Callers

nothing calls this directly

Calls 9

value_thousandsMethod · 0.80
show_gridMethod · 0.80
show_lineMethod · 0.80
sizeMethod · 0.80
finishMethod · 0.45
tick_directionMethod · 0.45
plotMethod · 0.45
xMethod · 0.45
fontMethod · 0.45

Tested by

no test coverage detected