I have an vector Vec<(i32,i32,i32)> and would like to create a 2D rainbow or gradient map. The third element of the vector would be the value for the color. I am using the plotters library. A colormap as in the image example. Any ideas or code examples?

I implemented the code below and got a result very close to what I want. I have no idea how to resolve the issue of including the colorbar, as a color reference, and how to smooth the field.
fn figura2(profun: Vec<(i32, i32, i32)>) -> Result<(), Box<dyn std::error::Error>> {
let root = BitMapBackend::new("plot_fold.png", (800, 600)).into_drawing_area();
root.fill(&WHITE)?;
let mut scatter_ctx = ChartBuilder::on(&root)
.top_x_label_area_size(40)
.y_label_area_size(55)
.build_cartesian_2d((1581001..1581542).step(1), 5500i32..0i32)?;
scatter_ctx
.configure_mesh()
.disable_x_mesh()
.disable_y_mesh()
.y_desc("OFFSET (m)")
.x_desc("ESTACAS (RP)")
.axis_desc_style(("sans-serif", 15))
.draw()?;
scatter_ctx.draw_series(profun.iter().map(|(x, y, v)| {
Rectangle::new(
[(*x, *y), (x + 1, y - 500)],
HSLColor(
240.0 / 360.0 - 240.0 / 360.0 * (*v as f64 / 150.0),
0.7,
0.1 + 0.4 * *v as f64 / 200.0,
)
.filled(),
)
}))?;
Ok(())
}

