Is there any recommended way to plot in rust?
I am using plotters, but it does not seem to integrate easily with ndarray.
More concretely something like
use plotters::prelude::*;
use ndarray::{Array, Array1, Zip};
use ndarray_rand::RandomExt;
use ndarray_rand::rand_distr::{Uniform, StandardNormal};
fn main() {
let drawing_area = BitMapBackend::new("outs/output.png", (600, 400))
.into_drawing_area();
drawing_area.fill(&WHITE).unwrap();
let mut chart = ChartBuilder::on(&drawing_area)
.caption("Figure Sample", ("Arial", 30))
.set_label_area_size(LabelAreaPosition::Left, 40)
.set_label_area_size(LabelAreaPosition::Bottom, 40)
.build_cartesian_2d(-10.0..(100.0*1.1), -10.0..100.0)
.unwrap();
let ip = Array::random(n_samples, Uniform::new(0., 10.));
chart.draw_series(
ip.map(|point| TriangleMarker::new((point, 2.*(*point)), 5, &BLUE.mix(0.3))),
)
.unwrap();
}
fails with the following error
error[E0277]: the trait bound `for<'b> &'b plotters::element::TriangleMarker<(&f64, f64), {integer}>: PointCollection<'b, (f64, f64)>` is not satisfied
--> charts/src/main.rs:69:7
|
69 | chart.draw_series(
| ^^^^^^^^^^^ the trait `for<'b> PointCollection<'b, (f64, f64)>` is not implemented for `&'b plotters::element::TriangleMarker<(&f64, f64), {integer}>`
|
= help: the following implementations were found:
<&'a plotters::element::TriangleMarker<Coord, Size> as PointCollection<'a, Coord>>
For more information about this error, try `rustc --explain E0277`.