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

Function main

crates/plotlars/examples/plotly_dimensions.rs:7–150  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

5};
6
7fn main() {
8 let penguins_dataset = CsvReader::new("data/penguins.csv")
9 .finish()
10 .unwrap()
11 .lazy()
12 .select([
13 col("species"),
14 col("sex").alias("gender"),
15 col("flipper_length_mm").cast(DataType::Int16),
16 col("body_mass_g").cast(DataType::Int16),
17 ])
18 .collect()
19 .unwrap();
20
21 let temperature_dataset = CsvReader::new("data/debilt_2023_temps.csv")
22 .has_header(true)
23 .try_parse_dates(true)
24 .finish()
25 .unwrap()
26 .lazy()
27 .with_columns(vec![
28 (col("tavg") / lit(10)).alias("tavg"),
29 (col("tmin") / lit(10)).alias("tmin"),
30 (col("tmax") / lit(10)).alias("tmax"),
31 ])
32 .collect()
33 .unwrap();
34
35 let animals_dataset = CsvReader::new("data/animal_statistics.csv")
36 .finish()
37 .unwrap();
38
39 let axis = Axis::new()
40 .show_line(true)
41 .tick_direction(TickDirection::OutSide)
42 .value_thousands(true);
43
44 let plot1 = TimeSeriesPlot::builder()
45 .data(&temperature_dataset)
46 .x("date")
47 .y("tavg")
48 .additional_series(vec!["tmin", "tmax"])
49 .colors(vec![Rgb(128, 128, 128), Rgb(0, 122, 255), Rgb(255, 128, 0)])
50 .lines(vec![Line::Solid, Line::Dot, Line::Dot])
51 .plot_title(
52 Text::from("De Bilt Temperature 2023")
53 .font("Arial Black")
54 .size(16),
55 )
56 .y_title(Text::from("temperature (°C)").size(13).x(-0.08))
57 // .legend_title(Text::from("Measure").size(12))
58 .legend(&Legend::new().x(0.1).y(0.9))
59 .build();
60
61 let plot2 = ScatterPlot::builder()
62 .data(&penguins_dataset)
63 .x("body_mass_g")
64 .y("flipper_length_mm")

Callers

nothing calls this directly

Calls 15

try_parse_datesMethod · 0.80
value_thousandsMethod · 0.80
show_lineMethod · 0.80
sizeMethod · 0.80
value_rangeMethod · 0.80
valuesMethod · 0.80
auto_sizeMethod · 0.80
titleMethod · 0.80
h_gapMethod · 0.80
v_gapMethod · 0.80
colsMethod · 0.80
rowsMethod · 0.80

Tested by

no test coverage detected