Plotting syntax



I am writing a crate to draw functions in Rust.

The output uses a Trait (implemented at the time only for GrayImage and RgbImage from the image crate). Thus it’s possible to use it with your own data structures.

To simplify the code, random sampling is used. Resulting in anti-aliased images and subpixel precision for free.

My question is not about the plotting algorithm, but the most intuitive way of using it.
My Idea right now:

Figure::new(-2.0 .. 2.0, -1.1 .. 1.1)
    .add(PlotItem::XY(|x: f64| sin(1.0 / x), 10_000)
    .add(PlotItem::Parametric(nautilus, 1_000_000))

The two arguments to the Figure::new call are Range arguments for the x- and y-dimension of the plot.
The second argument to PlotItem is the number of samples.

Another alternative:

Specifying the surface explicitly:

let mut image = image::RgbImage::from_pixel(500, 500, image::Rgb{data:[255,255,255]});
Figure::new(-2.0 .. 2.0, -1.1 .. 1.1)
    .add(PlotItem::XY(|x: f64| sin(1.0 / x), 10_000)
    .draw_on(&mut image)

Other ideas are welcome!