Skip to main content

heatmap/
heatmap.rs

1use plotlars::{ColorBar, HeatMap, Palette, Plot, Text, ValueExponent};
2use polars::prelude::*;
3
4fn main() {
5    let dataset = LazyCsvReader::new(PlRefPath::new("data/heatmap.csv"))
6        .finish()
7        .unwrap()
8        .collect()
9        .unwrap();
10
11    HeatMap::builder()
12        .data(&dataset)
13        .x("x")
14        .y("y")
15        .z("z")
16        .color_bar(
17            &ColorBar::new()
18                .length(0.7)
19                .value_exponent(ValueExponent::None)
20                .separate_thousands(true)
21                .tick_length(5)
22                .tick_step(2500.0),
23        )
24        .plot_title(Text::from("Heat Map").font("Arial").size(18))
25        .color_scale(Palette::Viridis)
26        .build()
27        .plot();
28}