From 1a6ce38bc8dde03c542c105ed177b094e230fba7 Mon Sep 17 00:00:00 2001 From: Christophe Troestler Date: Sun, 3 Mar 2024 13:07:50 +0100 Subject: [PATCH] Add the bare bones of a `contour` function --- src/lib.rs | 53 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) diff --git a/src/lib.rs b/src/lib.rs index 459ca1d..925d16d 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -445,6 +445,29 @@ impl Axes { } + pub fn contour<'a>(&'a mut self, ) -> Contour<'a> { + Contour { + axes: self, + options: PlotOptions::new(), + } + } + + pub fn contour_fun<'a, F>( + &'a mut self, + f: F, + ab: [f64; 2], + cd: [f64; 2], + ) -> ContourFun<'a, F> + where F: FnMut(f64, f64) -> f64 { + ContourFun { + axes: self, + options: PlotOptions::new(), + f, ab, cd, + n1: 100, + n2: 100, + } + } + #[must_use] pub fn scatter(&mut self, x: D, y: D) -> &mut Self where D: AsRef<[f64]> { @@ -801,6 +824,36 @@ where F: FnMut(f64) -> f64 { } +#[must_use] +pub struct Contour<'a> { + axes: &'a Axes, + options: PlotOptions<'a>, +} + +impl<'a> Contour<'a> { + set_plotoptions!(); + +} + + +#[must_use] +pub struct ContourFun<'a, F> { + axes: &'a Axes, + options: PlotOptions<'a>, + f: F, + ab: [f64; 2], + cd: [f64; 2], + n1: usize, + n2: usize, +} + +impl<'a, F> ContourFun<'a, F> +where F: FnMut(f64, f64) -> f64 { + set_plotoptions!(); + +} + + impl Line2D { fn set_kw(&self, prop: &str, v: impl ToPyObject) { Python::with_gil(|py| {