@@ -839,10 +839,11 @@ def contour(self, X, Y, Z, levels=10, **kwargs):
839839 ========== ================================================
840840 *X*, *Y*, Data values as numpy.arrays
841841 *Z*
842- *levels* Number of levels to use, defaults to 10. Can
843- also be a tuple of specific levels.
844842 *extend3d* Whether to extend contour in 3D (default: False)
845843 *stride* Stride (step size) for extending contour
844+ *zdir* The direction to use: x, y or z (default)
845+ *offset* If specified plot a projection of the contour
846+ lines on this position in plane normal to zdir
846847 ========== ================================================
847848
848849 Other keyword arguments are passed on to
@@ -851,16 +852,22 @@ def contour(self, X, Y, Z, levels=10, **kwargs):
851852
852853 extend3d = kwargs .pop ('extend3d' , False )
853854 stride = kwargs .pop ('stride' , 5 )
854- nlevels = kwargs .pop ('nlevels' , 15 )
855+ zdir = kwargs .pop ('zdir' , 'z' )
856+ offset = kwargs .pop ('offset' , None )
855857
856858 had_data = self .has_data ()
857- cset = Axes .contour (self , X , Y , Z , levels , ** kwargs )
858859
860+ jX , jY , jZ = art3d .juggle_axes (X , Y , Z , zdir )
861+ cset = Axes .contour (self , jX , jY , jZ , ** kwargs )
862+
863+ zdir = '-' + zdir
859864 if extend3d :
860865 self ._3d_extend_contour (cset , stride )
861866 else :
862867 for z , linec in zip (cset .levels , cset .collections ):
863- art3d .line_collection_2d_to_3d (linec , z )
868+ if offset is not None :
869+ z = offset
870+ art3d .line_collection_2d_to_3d (linec , z , zdir = zdir )
864871
865872 self .auto_scale_xyz (X , Y , Z , had_data )
866873 return cset
0 commit comments