()
| 13 | } |
| 14 | |
| 15 | fn regular_grid_example() { |
| 16 | let dataset1 = CsvReader::new("data/animal_statistics.csv") |
| 17 | .finish() |
| 18 | .unwrap(); |
| 19 | |
| 20 | let plot1 = BarPlot::builder() |
| 21 | .data(&dataset1) |
| 22 | .labels("animal") |
| 23 | .values("value") |
| 24 | .orientation(Orientation::Vertical) |
| 25 | .group("gender") |
| 26 | .sort_groups_by(|a, b| a.len().cmp(&b.len())) |
| 27 | .error("error") |
| 28 | .colors(vec![Rgb(255, 127, 80), Rgb(64, 224, 208)]) |
| 29 | .plot_title(Text::from("Bar Plot").x(-0.05).y(1.35).size(14)) |
| 30 | .y_title(Text::from("value").x(-0.055).y(0.76)) |
| 31 | .x_title(Text::from("animal").x(0.97).y(-0.2)) |
| 32 | .legend( |
| 33 | &Legend::new() |
| 34 | .orientation(Orientation::Horizontal) |
| 35 | .x(0.4) |
| 36 | .y(1.2), |
| 37 | ) |
| 38 | .build(); |
| 39 | |
| 40 | let dataset2 = CsvReader::new("data/penguins.csv") |
| 41 | .finish() |
| 42 | .unwrap() |
| 43 | .lazy() |
| 44 | .select([ |
| 45 | col("species"), |
| 46 | col("sex").alias("gender"), |
| 47 | col("flipper_length_mm").cast(DataType::Int16), |
| 48 | col("body_mass_g").cast(DataType::Int16), |
| 49 | ]) |
| 50 | .collect() |
| 51 | .unwrap(); |
| 52 | |
| 53 | let axis = Axis::new() |
| 54 | .show_line(true) |
| 55 | .tick_direction(TickDirection::OutSide) |
| 56 | .value_thousands(true); |
| 57 | |
| 58 | let plot2 = ScatterPlot::builder() |
| 59 | .data(&dataset2) |
| 60 | .x("body_mass_g") |
| 61 | .y("flipper_length_mm") |
| 62 | .group("species") |
| 63 | .sort_groups_by(|a, b| { |
| 64 | if a.len() == b.len() { |
| 65 | a.cmp(b) |
| 66 | } else { |
| 67 | a.len().cmp(&b.len()) |
| 68 | } |
| 69 | }) |
| 70 | .opacity(0.5) |
| 71 | .size(12) |
| 72 | .colors(vec![Rgb(178, 34, 34), Rgb(65, 105, 225), Rgb(255, 140, 0)]) |
no test coverage detected