@@ -964,7 +964,7 @@ def changed(self):
964
964
label .set_color (self .labelMappable .to_rgba (cv ))
965
965
super ().changed ()
966
966
967
- def _autolev (self , N , * , using_default ):
967
+ def _autolev (self , N ):
968
968
"""
969
969
Select contour levels to span the data.
970
970
@@ -978,16 +978,20 @@ def _autolev(self, N, *, using_default):
978
978
a single contour boundary, say at z = 0, requires only
979
979
one contour line, but two filled regions, and therefore
980
980
three levels to provide boundaries for both regions.
981
+
982
+ Parameters
983
+ ----------
984
+ N : int | None
981
985
"""
982
986
if self .locator is None :
983
987
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 :
987
989
self .locator = ticker .LogLocator ()
988
990
else :
989
991
self .locator = ticker .LogLocator (numticks = N )
990
992
else :
993
+ if N is None :
994
+ N = 7 # Hard coded default
991
995
self .locator = ticker .MaxNLocator (N + 1 , min_n_ticks = 1 )
992
996
993
997
lev = self .locator .tick_values (self .zmin , self .zmax )
@@ -1017,23 +1021,23 @@ def _process_contour_level_args(self, args, z_dtype):
1017
1021
"""
1018
1022
Determine the contour levels and store in self.levels.
1019
1023
"""
1020
- if self .levels is None :
1024
+ levels_arg = self .levels
1025
+ if levels_arg is None :
1021
1026
if args :
1027
+ # Set if levels manually provided
1022
1028
levels_arg = args [0 ]
1023
1029
elif np .issubdtype (z_dtype , bool ):
1030
+ # Set default values for bool data types
1024
1031
if self .filled :
1025
1032
levels_arg = [0 , .5 , 1 ]
1026
1033
else :
1027
1034
levels_arg = [.5 ]
1028
- else :
1029
- levels_arg = 7 # Default, hard-wired.
1030
- else :
1031
- levels_arg = self .levels
1032
1035
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 )
1035
1038
else :
1036
1039
self .levels = np .asarray (levels_arg , np .float64 )
1040
+
1037
1041
if self .filled and len (self .levels ) < 2 :
1038
1042
raise ValueError ("Filled contours require at least 2 levels." )
1039
1043
if len (self .levels ) > 1 and np .min (np .diff (self .levels )) <= 0.0 :
0 commit comments