377377figtitle
378378 Alias for `suptitle`.
379379suptitle : str, optional
380- The figure "super" title, centered between the left edge of the lefmost
381- column of subplots and the right edge of the rightmost column of subplots, and
382- automatically offset above figure titles. This is an improvement on matplotlib's
383- "super" title, which just centers the text between figure edges.
380+ The figure "super" title, centered between the left edge of the leftmost
381+ subplot and the right edge of the rightmost subplot.
384382suptitlepad : float, default: :rc:`suptitle.pad`
385383 The padding between the super title and the axes content.
386384 %(units.pt)s
@@ -1059,7 +1057,10 @@ def _add_colorbar(
10591057 pop = _pop_params (kwargs , cax ._parse_colorbar_arg , ignore_internal = True )
10601058 locator_default = formatter_default = None
10611059 if pop :
1062- warnings ._warn_proplot (f'Input is already a ScalarMappable. Ignoring unused keyword arg(s): { pop } ' ) # noqa: E501
1060+ warnings ._warn_proplot (
1061+ f'Input is already a ScalarMappable. '
1062+ f'Ignoring unused keyword arg(s): { pop } '
1063+ )
10631064 else :
10641065 result = cax ._parse_colorbar_arg (mappable , values , ** kwargs )
10651066 mappable , locator_default , formatter_default , kwargs = result
@@ -1081,6 +1082,8 @@ def _add_colorbar(
10811082 # Parse the tick locators and formatters
10821083 # NOTE: This auto constructs minor DiscreteLocotors from major DiscreteLocator
10831084 # instances (but bypasses if labels are categorical).
1085+ # NOTE: Almost always DiscreteLocator will be associated with DiscreteNorm.
1086+ # But otherwise disable minor ticks or else get issues (see mpl #22233).
10841087 name = 'y' if kwargs .get ('orientation' ) == 'vertical' else 'x'
10851088 axis = cax .yaxis if kwargs .get ('orientation' ) == 'vertical' else cax .xaxis
10861089 locator = _not_none (locator , locator_default , None )
@@ -1092,16 +1095,19 @@ def _add_colorbar(
10921095 locator = constructor .Locator (locator , ** locator_kw )
10931096 if minorlocator is not None :
10941097 minorlocator = constructor .Locator (minorlocator , ** minorlocator_kw )
1095- elif isinstance (locator , pticker .DiscreteLocator ):
1096- if categorical : # never add default minor ticks
1098+ if isinstance (locator , pticker .DiscreteLocator ):
1099+ if categorical : # no minor ticks and convert DiscreteLocator
1100+ locator = mticker .FixedLocator (np .array (locator .locs ))
1101+ elif minorlocator is not None :
10971102 pass
10981103 elif tickminor or tickminor is None :
10991104 minorlocator = pticker .DiscreteLocator (np .array (locator .locs ), minor = True ) # noqa: E501
1100- if tickminor is None :
1101- if discrete or categorical : # never use the default minor locator
1102- tickminor = False
1103- else :
1104- tickminor = rc [name + 'tick.minor.visible' ]
1105+ if tickminor is not None : # whether to apply minorticks_on()
1106+ pass
1107+ elif discrete or categorical : # never use the default minor locator
1108+ tickminor = False
1109+ else :
1110+ tickminor = rc [name + 'tick.minor.visible' ]
11051111
11061112 # Special handling for colorbar keyword arguments
11071113 # WARNING: Critical to not pass empty major locators in matplotlib < 3.5
@@ -1640,7 +1646,7 @@ def _parse_colorbar_arg(
16401646 ):
16411647 mappable = [obj [0 ] for obj in mappable ]
16421648
1643- # A colormap instance
1649+ # Colormap instance
16441650 if isinstance (mappable , mcolors .Colormap ) or isinstance (mappable , str ):
16451651 cmap = constructor .Colormap (mappable )
16461652 if values is None and isinstance (cmap , pcolors .DiscreteColormap ):
@@ -1706,12 +1712,12 @@ def _parse_colorbar_arg(
17061712 if val is None :
17071713 val = i
17081714 ticks .append (val )
1709- if not any (isinstance (_ , str ) for _ in ticks ):
1710- locator = pticker .DiscreteLocator (ticks )
1711- else :
1715+ if any (isinstance (_ , str ) for _ in ticks ):
17121716 formatter = mticker .FixedFormatter (list (map (str , ticks )))
17131717 ticks = np .arange (len (ticks ))
17141718 locator = mticker .FixedLocator (ticks )
1719+ else :
1720+ locator = pticker .DiscreteLocator (ticks )
17151721 if len (ticks ) == 1 :
17161722 levels = [ticks [0 ] - 1 , ticks [0 ] + 1 ]
17171723 else :
0 commit comments