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