@@ -450,7 +450,9 @@ impl Axes {
450450 /// }
451451 /// }
452452 /// let (fig, [[mut ax]]) = plt::subplots()?;
453- /// ax.contour(x.as_slice().unwrap(), y.as_slice().unwrap(), &z).plot();
453+ /// ax.contour(x.as_slice().unwrap(), y.as_slice().unwrap(), &z)
454+ /// .levels(&[0.2, 0.5, 0.8])
455+ /// .plot();
454456 /// fig.save().to_file("target/contour.pdf")?;
455457 /// # Ok::<(), matplotlib::Error>(())
456458 /// ```
@@ -876,6 +878,13 @@ impl QuadContourSet {
876878 }
877879}
878880
881+ macro_rules! set_contour_options { ( ) => {
882+ pub fn levels( mut self , levels: & ' a [ f64 ] ) -> Self {
883+ self . levels = Some ( levels) ;
884+ self
885+ }
886+ } }
887+
879888#[ must_use]
880889pub struct Contour < ' a , D > {
881890 axes : & ' a Axes ,
@@ -889,6 +898,7 @@ pub struct Contour<'a, D> {
889898impl < ' a , D > Contour < ' a , D >
890899where D : AsRef < [ f64 ] > {
891900 set_plotoptions ! ( ) ;
901+ set_contour_options ! ( ) ;
892902
893903 pub fn plot ( & self ) -> QuadContourSet {
894904 Python :: with_gil ( |py| {
@@ -926,6 +936,7 @@ pub struct ContourFun<'a, F> {
926936impl < ' a , F > ContourFun < ' a , F >
927937where F : FnMut ( f64 , f64 ) -> f64 {
928938 set_plotoptions ! ( ) ;
939+ set_contour_options ! ( ) ;
929940
930941 pub fn plot ( & mut self ) -> QuadContourSet {
931942 let mut x = Vec :: with_capacity ( self . n1 ) ;
0 commit comments