@@ -1117,15 +1117,20 @@ def _autolev(self, N):
11171117
11181118 return lev [i0 :i1 ]
11191119
1120- def _process_contour_level_args (self , args ):
1120+ def _process_contour_level_args (self , args , z_dtype ):
11211121 """
11221122 Determine the contour levels and store in self.levels.
11231123 """
11241124 if self .levels is None :
1125- if len (args ) == 0 :
1126- levels_arg = 7 # Default, hard-wired.
1127- else :
1125+ if args :
11281126 levels_arg = args [0 ]
1127+ elif np .issubdtype (z_dtype , bool ):
1128+ if self .filled :
1129+ levels_arg = [0 , .5 , 1 ]
1130+ else :
1131+ levels_arg = [.5 ]
1132+ else :
1133+ levels_arg = 7 # Default, hard-wired.
11291134 else :
11301135 levels_arg = self .levels
11311136 if isinstance (levels_arg , Integral ):
@@ -1447,12 +1452,12 @@ def _contour_args(self, args, kwargs):
14471452 fn = 'contour'
14481453 nargs = len (args )
14491454 if nargs <= 2 :
1450- z = ma .asarray (args [0 ], dtype = np .float64 )
1455+ z , * args = args
1456+ z = ma .asarray (z )
14511457 x , y = self ._initialize_x_y (z )
1452- args = args [1 :]
14531458 elif nargs <= 4 :
1454- x , y , z = self . _check_xyz ( args [: 3 ], kwargs )
1455- args = args [ 3 :]
1459+ x , y , z_orig , * args = args
1460+ x , y , z = self . _check_xyz ( x , y , z_orig , kwargs )
14561461 else :
14571462 raise _api .nargs_error (fn , takes = "from 1 to 4" , given = nargs )
14581463 z = ma .masked_invalid (z , copy = False )
@@ -1462,20 +1467,19 @@ def _contour_args(self, args, kwargs):
14621467 z = ma .masked_where (z <= 0 , z )
14631468 _api .warn_external ('Log scale: values of z <= 0 have been masked' )
14641469 self .zmin = float (z .min ())
1465- self ._process_contour_level_args (args )
1470+ self ._process_contour_level_args (args , z . dtype )
14661471 return (x , y , z )
14671472
1468- def _check_xyz (self , args , kwargs ):
1473+ def _check_xyz (self , x , y , z , kwargs ):
14691474 """
14701475 Check that the shapes of the input arrays match; if x and y are 1D,
14711476 convert them to 2D using meshgrid.
14721477 """
1473- x , y = args [:2 ]
14741478 x , y = self .axes ._process_unit_info ([("x" , x ), ("y" , y )], kwargs )
14751479
14761480 x = np .asarray (x , dtype = np .float64 )
14771481 y = np .asarray (y , dtype = np .float64 )
1478- z = ma .asarray (args [ 2 ], dtype = np . float64 )
1482+ z = ma .asarray (z )
14791483
14801484 if z .ndim != 2 :
14811485 raise TypeError (f"Input z must be 2D, not { z .ndim } D" )
0 commit comments