scatter3dplot/
scatter3dplot.rs

1use plotlars::{Legend, Plot, Rgb, Scatter3dPlot, Shape};
2use polars::prelude::*;
3
4fn main() {
5    let dataset = LazyCsvReader::new(PlPath::new("data/penguins.csv"))
6        .finish()
7        .unwrap()
8        .select([
9            col("species"),
10            col("sex").alias("gender"),
11            col("bill_length_mm").cast(DataType::Float32),
12            col("flipper_length_mm").cast(DataType::Int16),
13            col("body_mass_g").cast(DataType::Int16),
14        ])
15        .collect()
16        .unwrap();
17
18    Scatter3dPlot::builder()
19        .data(&dataset)
20        .x("body_mass_g")
21        .y("flipper_length_mm")
22        .z("bill_length_mm")
23        .group("species")
24        .opacity(0.25)
25        .size(8)
26        .colors(vec![Rgb(178, 34, 34), Rgb(65, 105, 225), Rgb(255, 140, 0)])
27        .shapes(vec![Shape::Circle, Shape::Square, Shape::Diamond])
28        .plot_title("Scatter 3D Plot")
29        .legend(&Legend::new().x(0.6))
30        .build()
31        .plot();
32}