@@ -964,7 +964,7 @@ def changed(self):
964964 label .set_color (self .labelMappable .to_rgba (cv ))
965965 super ().changed ()
966966
967- def _autolev (self , N , * , using_default ):
967+ def _autolev (self , N ):
968968 """
969969 Select contour levels to span the data.
970970
@@ -978,16 +978,20 @@ def _autolev(self, N, *, using_default):
978978 a single contour boundary, say at z = 0, requires only
979979 one contour line, but two filled regions, and therefore
980980 three levels to provide boundaries for both regions.
981+
982+ Parameters
983+ ----------
984+ N : int | None
981985 """
982986 if self .locator is None :
983987 if self .logscale :
984- if using_default :
985- # Let log locator choose instead of using hard coded value
986- # set in self._process_contour_level_args()
988+ if N is None :
987989 self .locator = ticker .LogLocator ()
988990 else :
989991 self .locator = ticker .LogLocator (numticks = N )
990992 else :
993+ if N is None :
994+ N = 7 # Hard coded default
991995 self .locator = ticker .MaxNLocator (N + 1 , min_n_ticks = 1 )
992996
993997 lev = self .locator .tick_values (self .zmin , self .zmax )
@@ -1017,23 +1021,23 @@ def _process_contour_level_args(self, args, z_dtype):
10171021 """
10181022 Determine the contour levels and store in self.levels.
10191023 """
1020- if self .levels is None :
1024+ levels_arg = self .levels
1025+ if levels_arg is None :
10211026 if args :
1027+ # Set if levels manually provided
10221028 levels_arg = args [0 ]
10231029 elif np .issubdtype (z_dtype , bool ):
1030+ # Set default values for bool data types
10241031 if self .filled :
10251032 levels_arg = [0 , .5 , 1 ]
10261033 else :
10271034 levels_arg = [.5 ]
1028- else :
1029- levels_arg = 7 # Default, hard-wired.
1030- else :
1031- levels_arg = self .levels
10321035
1033- if isinstance (levels_arg , Integral ):
1034- self .levels = self ._autolev (levels_arg , using_default = self . levels is None )
1036+ if isinstance (levels_arg , ( Integral , None ) ):
1037+ self .levels = self ._autolev (levels_arg )
10351038 else :
10361039 self .levels = np .asarray (levels_arg , np .float64 )
1040+
10371041 if self .filled and len (self .levels ) < 2 :
10381042 raise ValueError ("Filled contours require at least 2 levels." )
10391043 if len (self .levels ) > 1 and np .min (np .diff (self .levels )) <= 0.0 :
0 commit comments