I just want to plot data from a Polars datafram into a plotters image. I need help. I followed Iterate over rows polars rust to have this :
let iters = dataset
.columns(["x", "y"])?
.iter()
.map(|s| Ok(s.f64()?.into_iter()))
.collect::<Result<Vec<_>, Box<dyn Error>>>()?;
and I want to do something like
chart
.draw_series(
x.zip(y)map(|(x, y)| Circle::new((x, x), 3, BLUE.filled())),
)?
.label("data")
.legend(|(x, y)| Circle::new((x, y), 3, BLUE.filled()));
But it doesnt work. I need help. Maybe I am missing something,but I think it should be easy to use the biggest dataframe library with the biggest plotting library.
All I could make work is using one column with
let mut iters = dataset.groundtruth
.columns(["x", "y"])?
.iter()
.map(|s| Ok(s.f64()?.into_iter()))
.collect::<Result<Vec<_>, Box<dyn Error>>>()?;
let x = &mut iters[0];
chart
.draw_series(
// x.filter(|x| x.is_some())
x.map(|(x)| Circle::new((x.unwrap(), x.unwrap()), 3, BLUE.filled())),
)?
.label("data")
.legend(|(x, y)| Circle::new((x, y), 3, BLUE.filled()));
I really like rust, but using dataframes and plotting library is a pain. Maybe it is a lifetime issue.