@@ -1192,6 +1192,12 @@ def _contour_level_args(self, z, args):
11921192 if self .filled and len (self .levels ) < 2 :
11931193 raise ValueError ("Filled contours require at least 2 levels." )
11941194
1195+ if len (self .levels ) > 1 and np .amin (np .diff (self .levels )) <= 0.0 :
1196+ if hasattr (self , '_corner_mask' ) and self ._corner_mask == 'legacy' :
1197+ warnings .warn ("Contour levels are not increasing" )
1198+ else :
1199+ raise ValueError ("Contour levels must be increasing" )
1200+
11951201 def _process_levels (self ):
11961202 """
11971203 Assign values to :attr:`layers` based on :attr:`levels`,
@@ -1442,16 +1448,16 @@ def _process_args(self, *args, **kwargs):
14421448 else :
14431449 contour_generator = args [0 ]._contour_generator
14441450 else :
1451+ self ._corner_mask = kwargs .get ('corner_mask' , None )
1452+ if self ._corner_mask is None :
1453+ self ._corner_mask = mpl .rcParams ['contour.corner_mask' ]
1454+
14451455 x , y , z = self ._contour_args (args , kwargs )
14461456
14471457 _mask = ma .getmask (z )
14481458 if _mask is ma .nomask or not _mask .any ():
14491459 _mask = None
14501460
1451- self ._corner_mask = kwargs .get ('corner_mask' , None )
1452- if self ._corner_mask is None :
1453- self ._corner_mask = mpl .rcParams ['contour.corner_mask' ]
1454-
14551461 if self ._corner_mask == 'legacy' :
14561462 cbook .warn_deprecated ('1.5' ,
14571463 name = "corner_mask='legacy'" ,
@@ -1674,13 +1680,15 @@ def _initialize_x_y(self, z):
16741680 contour(Z,V)
16751681 contour(X,Y,Z,V)
16761682
1677- draw contour lines at the values specified in sequence *V*
1683+ draw contour lines at the values specified in sequence *V*,
1684+ which must be in increasing order.
16781685
16791686 ::
16801687
16811688 contourf(..., V)
16821689
1683- fill the ``len(V)-1`` regions between the values in *V*
1690+ fill the ``len(V)-1`` regions between the values in *V*,
1691+ which must be in increasing order.
16841692
16851693 ::
16861694
@@ -1743,8 +1751,8 @@ def _initialize_x_y(self, z):
17431751
17441752 *levels*: [level0, level1, ..., leveln]
17451753 A list of floating point numbers indicating the level
1746- curves to draw; e.g., to draw just the zero contour pass
1747- ``levels=[0]``
1754+ curves to draw, in increasing order ; e.g., to draw just
1755+ the zero contour pass ``levels=[0]``
17481756
17491757 *origin*: [ *None* | 'upper' | 'lower' | 'image' ]
17501758 If *None*, the first value of *Z* will correspond to the
0 commit comments