377
377
figtitle
378
378
Alias for `suptitle`.
379
379
suptitle : 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.
384
382
suptitlepad : float, default: :rc:`suptitle.pad`
385
383
The padding between the super title and the axes content.
386
384
%(units.pt)s
@@ -1059,7 +1057,10 @@ def _add_colorbar(
1059
1057
pop = _pop_params (kwargs , cax ._parse_colorbar_arg , ignore_internal = True )
1060
1058
locator_default = formatter_default = None
1061
1059
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
+ )
1063
1064
else :
1064
1065
result = cax ._parse_colorbar_arg (mappable , values , ** kwargs )
1065
1066
mappable , locator_default , formatter_default , kwargs = result
@@ -1081,6 +1082,8 @@ def _add_colorbar(
1081
1082
# Parse the tick locators and formatters
1082
1083
# NOTE: This auto constructs minor DiscreteLocotors from major DiscreteLocator
1083
1084
# 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).
1084
1087
name = 'y' if kwargs .get ('orientation' ) == 'vertical' else 'x'
1085
1088
axis = cax .yaxis if kwargs .get ('orientation' ) == 'vertical' else cax .xaxis
1086
1089
locator = _not_none (locator , locator_default , None )
@@ -1092,16 +1095,19 @@ def _add_colorbar(
1092
1095
locator = constructor .Locator (locator , ** locator_kw )
1093
1096
if minorlocator is not None :
1094
1097
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 :
1097
1102
pass
1098
1103
elif tickminor or tickminor is None :
1099
1104
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' ]
1105
1111
1106
1112
# Special handling for colorbar keyword arguments
1107
1113
# WARNING: Critical to not pass empty major locators in matplotlib < 3.5
@@ -1640,7 +1646,7 @@ def _parse_colorbar_arg(
1640
1646
):
1641
1647
mappable = [obj [0 ] for obj in mappable ]
1642
1648
1643
- # A colormap instance
1649
+ # Colormap instance
1644
1650
if isinstance (mappable , mcolors .Colormap ) or isinstance (mappable , str ):
1645
1651
cmap = constructor .Colormap (mappable )
1646
1652
if values is None and isinstance (cmap , pcolors .DiscreteColormap ):
@@ -1706,12 +1712,12 @@ def _parse_colorbar_arg(
1706
1712
if val is None :
1707
1713
val = i
1708
1714
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 ):
1712
1716
formatter = mticker .FixedFormatter (list (map (str , ticks )))
1713
1717
ticks = np .arange (len (ticks ))
1714
1718
locator = mticker .FixedLocator (ticks )
1719
+ else :
1720
+ locator = pticker .DiscreteLocator (ticks )
1715
1721
if len (ticks ) == 1 :
1716
1722
levels = [ticks [0 ] - 1 , ticks [0 ] + 1 ]
1717
1723
else :
0 commit comments