@@ -430,44 +430,51 @@ def __init__(self, ax, mappable=None, *, cmap=None,
430430self ._extend_cid2 = self .ax .callbacks .connect (
431431"ylim_changed" ,self ._do_extends )
432432
433+ @property
434+ def long_axis (self ):
435+ """Axis that has decorations (ticks, etc) on it."""
436+ if self .orientation == 'vertical' :
437+ return self .ax .yaxis
438+ return self .ax .xaxis
439+
433440@property
434441def locator (self ):
435442"""Major tick `.Locator` for the colorbar."""
436- return self ._long_axis () .get_major_locator ()
443+ return self .long_axis .get_major_locator ()
437444
438445@locator .setter
439446def locator (self ,loc ):
440- self ._long_axis () .set_major_locator (loc )
447+ self .long_axis .set_major_locator (loc )
441448self ._locator = loc
442449
443450@property
444451def minorlocator (self ):
445452"""Minor tick `.Locator` for the colorbar."""
446- return self ._long_axis () .get_minor_locator ()
453+ return self .long_axis .get_minor_locator ()
447454
448455@minorlocator .setter
449456def minorlocator (self ,loc ):
450- self ._long_axis () .set_minor_locator (loc )
457+ self .long_axis .set_minor_locator (loc )
451458self ._minorlocator = loc
452459
453460@property
454461def formatter (self ):
455462"""Major tick label `.Formatter` for the colorbar."""
456- return self ._long_axis () .get_major_formatter ()
463+ return self .long_axis .get_major_formatter ()
457464
458465@formatter .setter
459466def formatter (self ,fmt ):
460- self ._long_axis () .set_major_formatter (fmt )
467+ self .long_axis .set_major_formatter (fmt )
461468self ._formatter = fmt
462469
463470@property
464471def minorformatter (self ):
465472"""Minor tick `.Formatter` for the colorbar."""
466- return self ._long_axis () .get_minor_formatter ()
473+ return self .long_axis .get_minor_formatter ()
467474
468475@minorformatter .setter
469476def minorformatter (self ,fmt ):
470- self ._long_axis () .set_minor_formatter (fmt )
477+ self .long_axis .set_minor_formatter (fmt )
471478self ._minorformatter = fmt
472479
473480def _cbar_cla (self ):
@@ -526,7 +533,7 @@ def _draw_all(self):
526533else :
527534if mpl .rcParams ['xtick.minor.visible' ]:
528535self .minorticks_on ()
529- self ._long_axis () .set (label_position = self .ticklocation ,
536+ self .long_axis .set (label_position = self .ticklocation ,
530537ticks_position = self .ticklocation )
531538self ._short_axis ().set_ticks ([])
532539self ._short_axis ().set_ticks ([],minor = True )
@@ -545,7 +552,7 @@ def _draw_all(self):
545552# also adds the outline path to self.outline spine:
546553self ._do_extends ()
547554lower ,upper = self .vmin ,self .vmax
548- if self ._long_axis () .get_inverted ():
555+ if self .long_axis .get_inverted ():
549556# If the axis is inverted, we need to swap the vmin/vmax
550557lower ,upper = upper ,lower
551558if self .orientation == 'vertical' :
@@ -686,7 +693,7 @@ def _do_extends(self, ax=None):
686693if self .orientation == 'horizontal' :
687694xy = xy [:, ::- 1 ]
688695# add the patch
689- val = - 1 if self ._long_axis () .get_inverted ()else 0
696+ val = - 1 if self .long_axis .get_inverted ()else 0
690697color = self .cmap (self .norm (self ._values [val ]))
691698patch = mpatches .PathPatch (
692699mpath .Path (xy ),facecolor = color ,alpha = self .alpha ,
@@ -710,7 +717,7 @@ def _do_extends(self, ax=None):
710717if self .orientation == 'horizontal' :
711718xy = xy [:, ::- 1 ]
712719# add the patch
713- val = 0 if self ._long_axis () .get_inverted ()else - 1
720+ val = 0 if self .long_axis .get_inverted ()else - 1
714721color = self .cmap (self .norm (self ._values [val ]))
715722hatch_idx = len (self ._y )- 1
716723patch = mpatches .PathPatch (
@@ -812,9 +819,9 @@ def update_ticks(self):
812819 """
813820# Get the locator and formatter; defaults to self._locator if not None.
814821self ._get_ticker_locator_formatter ()
815- self ._long_axis () .set_major_locator (self ._locator )
816- self ._long_axis () .set_minor_locator (self ._minorlocator )
817- self ._long_axis () .set_major_formatter (self ._formatter )
822+ self .long_axis .set_major_locator (self ._locator )
823+ self .long_axis .set_minor_locator (self ._minorlocator )
824+ self .long_axis .set_major_formatter (self ._formatter )
818825
819826def _get_ticker_locator_formatter (self ):
820827"""
@@ -849,15 +856,15 @@ def _get_ticker_locator_formatter(self):
849856if locator is None :
850857# we haven't set the locator explicitly, so use the default
851858# for this axis:
852- locator = self ._long_axis () .get_major_locator ()
859+ locator = self .long_axis .get_major_locator ()
853860if minorlocator is None :
854- minorlocator = self ._long_axis () .get_minor_locator ()
861+ minorlocator = self .long_axis .get_minor_locator ()
855862
856863if minorlocator is None :
857864minorlocator = ticker .NullLocator ()
858865
859866if formatter is None :
860- formatter = self ._long_axis () .get_major_formatter ()
867+ formatter = self .long_axis .get_major_formatter ()
861868
862869self ._locator = locator
863870self ._formatter = formatter
@@ -881,12 +888,12 @@ def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):
881888 pass *labels*. In other cases, please use `~.Axes.tick_params`.
882889 """
883890if np .iterable (ticks ):
884- self ._long_axis () .set_ticks (ticks ,labels = labels ,minor = minor ,
891+ self .long_axis .set_ticks (ticks ,labels = labels ,minor = minor ,
885892** kwargs )
886- self ._locator = self ._long_axis () .get_major_locator ()
893+ self ._locator = self .long_axis .get_major_locator ()
887894else :
888895self ._locator = ticks
889- self ._long_axis () .set_major_locator (self ._locator )
896+ self .long_axis .set_major_locator (self ._locator )
890897self .stale = True
891898
892899def get_ticks (self ,minor = False ):
@@ -899,9 +906,9 @@ def get_ticks(self, minor=False):
899906 if True return the minor ticks.
900907 """
901908if minor :
902- return self ._long_axis () .get_minorticklocs ()
909+ return self .long_axis .get_minorticklocs ()
903910else :
904- return self ._long_axis () .get_majorticklocs ()
911+ return self .long_axis .get_majorticklocs ()
905912
906913def set_ticklabels (self ,ticklabels ,* ,minor = False ,** kwargs ):
907914"""
@@ -936,7 +943,7 @@ def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
936943 **kwargs
937944 `.Text` properties for the labels.
938945 """
939- self ._long_axis () .set_ticklabels (ticklabels ,minor = minor ,** kwargs )
946+ self .long_axis .set_ticklabels (ticklabels ,minor = minor ,** kwargs )
940947
941948def minorticks_on (self ):
942949"""
@@ -948,7 +955,7 @@ def minorticks_on(self):
948955def minorticks_off (self ):
949956"""Turn the minor ticks of the colorbar off."""
950957self ._minorlocator = ticker .NullLocator ()
951- self ._long_axis () .set_minor_locator (self ._minorlocator )
958+ self .long_axis .set_minor_locator (self ._minorlocator )
952959
953960def set_label (self ,label ,* ,loc = None ,** kwargs ):
954961"""
@@ -1013,7 +1020,7 @@ def _set_scale(self, scale, **kwargs):
10131020 `matplotlib.scale.register_scale`. These scales can then also
10141021 be used here.
10151022 """
1016- self ._long_axis () ._set_axes_scale (scale ,** kwargs )
1023+ self .long_axis ._set_axes_scale (scale ,** kwargs )
10171024
10181025def remove (self ):
10191026"""
@@ -1285,20 +1292,14 @@ def _get_extension_lengths(self, frac, automin, automax, default=0.05):
12851292
12861293def _extend_lower (self ):
12871294"""Return whether the lower limit is open ended."""
1288- minmax = "max" if self ._long_axis () .get_inverted ()else "min"
1295+ minmax = "max" if self .long_axis .get_inverted ()else "min"
12891296return self .extend in ('both' ,minmax )
12901297
12911298def _extend_upper (self ):
12921299"""Return whether the upper limit is open ended."""
1293- minmax = "min" if self ._long_axis () .get_inverted ()else "max"
1300+ minmax = "min" if self .long_axis .get_inverted ()else "max"
12941301return self .extend in ('both' ,minmax )
12951302
1296- def _long_axis (self ):
1297- """Return the long axis"""
1298- if self .orientation == 'vertical' :
1299- return self .ax .yaxis
1300- return self .ax .xaxis
1301-
13021303def _short_axis (self ):
13031304"""Return the short axis"""
13041305if self .orientation == 'vertical' :