bar_chart/bar_chart.rs
1use ggplot_rs::prelude::*;
2use polars::prelude::*;
3
4fn main() -> Result<(), Box<dyn std::error::Error>> {
5 let df = df! {
6 "fruit" => ["Apple", "Apple", "Apple", "Banana", "Banana",
7 "Cherry", "Cherry", "Cherry", "Cherry", "Date"],
8 }?;
9
10 GGPlot::new(df)
11 .aes(Aes::new().x("fruit"))
12 .geom_bar()
13 .title("Fruit Counts")
14 .xlab("Fruit")
15 .ylab("Count")
16 .save("bar_chart.svg")?;
17
18 println!("Saved bar_chart.svg");
19 Ok(())
20}