use charton::prelude::*;
use polars::prelude::*;
use std::error::Error;
fn main() -> Result<(), Box<dyn Error>> {
let df = CsvReadOptions::default()
.with_has_header(true)
.try_into_reader_with_file_path(Some("./datasets/iris.csv".into()))?
.finish()?;
Chart::build(&df.select(["species", "sepal_length"])?)?
.transform_window(
WindowTransform::new(WindowFieldDef::new(
"sepal_length",
WindowOnlyOp::CumeDist,
"ecdf", ))
.with_groupby("species")
.with_normalize(false),
)?
.mark_line()?
.configure_line(|l| l.with_interpolation("step")) .encode((x("sepal_length"), y("ecdf"), color("species")))?
.with_title("Empirical Cumulative Distribution")
.save("docs/src/images/cumulative_frequency.svg")?;
Ok(())
}