@@ -433,46 +433,48 @@ def __init__(self, ax, mappable=None, *, cmap=None,
433433@property
434434def long_axis (self ):
435435"""Axis that has decorations (ticks, etc) on it."""
436- return self ._long_axis ()
436+ if self .orientation == 'vertical' :
437+ return self .ax .yaxis
438+ return self .ax .xaxis
437439
438440@property
439441def locator (self ):
440442"""Major tick `.Locator` for the colorbar."""
441- return self ._long_axis () .get_major_locator ()
443+ return self .long_axis .get_major_locator ()
442444
443445@locator .setter
444446def locator (self ,loc ):
445- self ._long_axis () .set_major_locator (loc )
447+ self .long_axis .set_major_locator (loc )
446448self ._locator = loc
447449
448450@property
449451def minorlocator (self ):
450452"""Minor tick `.Locator` for the colorbar."""
451- return self ._long_axis () .get_minor_locator ()
453+ return self .long_axis .get_minor_locator ()
452454
453455@minorlocator .setter
454456def minorlocator (self ,loc ):
455- self ._long_axis () .set_minor_locator (loc )
457+ self .long_axis .set_minor_locator (loc )
456458self ._minorlocator = loc
457459
458460@property
459461def formatter (self ):
460462"""Major tick label `.Formatter` for the colorbar."""
461- return self ._long_axis () .get_major_formatter ()
463+ return self .long_axis .get_major_formatter ()
462464
463465@formatter .setter
464466def formatter (self ,fmt ):
465- self ._long_axis () .set_major_formatter (fmt )
467+ self .long_axis .set_major_formatter (fmt )
466468self ._formatter = fmt
467469
468470@property
469471def minorformatter (self ):
470472"""Minor tick `.Formatter` for the colorbar."""
471- return self ._long_axis () .get_minor_formatter ()
473+ return self .long_axis .get_minor_formatter ()
472474
473475@minorformatter .setter
474476def minorformatter (self ,fmt ):
475- self ._long_axis () .set_minor_formatter (fmt )
477+ self .long_axis .set_minor_formatter (fmt )
476478self ._minorformatter = fmt
477479
478480def _cbar_cla (self ):
@@ -531,7 +533,7 @@ def _draw_all(self):
531533else :
532534if mpl .rcParams ['xtick.minor.visible' ]:
533535self .minorticks_on ()
534- self ._long_axis () .set (label_position = self .ticklocation ,
536+ self .long_axis .set (label_position = self .ticklocation ,
535537ticks_position = self .ticklocation )
536538self ._short_axis ().set_ticks ([])
537539self ._short_axis ().set_ticks ([],minor = True )
@@ -550,7 +552,7 @@ def _draw_all(self):
550552# also adds the outline path to self.outline spine:
551553self ._do_extends ()
552554lower ,upper = self .vmin ,self .vmax
553- if self ._long_axis () .get_inverted ():
555+ if self .long_axis .get_inverted ():
554556# If the axis is inverted, we need to swap the vmin/vmax
555557lower ,upper = upper ,lower
556558if self .orientation == 'vertical' :
@@ -691,7 +693,7 @@ def _do_extends(self, ax=None):
691693if self .orientation == 'horizontal' :
692694xy = xy [:, ::- 1 ]
693695# add the patch
694- val = - 1 if self ._long_axis () .get_inverted ()else 0
696+ val = - 1 if self .long_axis .get_inverted ()else 0
695697color = self .cmap (self .norm (self ._values [val ]))
696698patch = mpatches .PathPatch (
697699mpath .Path (xy ),facecolor = color ,alpha = self .alpha ,
@@ -715,7 +717,7 @@ def _do_extends(self, ax=None):
715717if self .orientation == 'horizontal' :
716718xy = xy [:, ::- 1 ]
717719# add the patch
718- val = 0 if self ._long_axis () .get_inverted ()else - 1
720+ val = 0 if self .long_axis .get_inverted ()else - 1
719721color = self .cmap (self .norm (self ._values [val ]))
720722hatch_idx = len (self ._y )- 1
721723patch = mpatches .PathPatch (
@@ -817,9 +819,9 @@ def update_ticks(self):
817819 """
818820# Get the locator and formatter; defaults to self._locator if not None.
819821self ._get_ticker_locator_formatter ()
820- self ._long_axis () .set_major_locator (self ._locator )
821- self ._long_axis () .set_minor_locator (self ._minorlocator )
822- 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 )
823825
824826def _get_ticker_locator_formatter (self ):
825827"""
@@ -854,15 +856,15 @@ def _get_ticker_locator_formatter(self):
854856if locator is None :
855857# we haven't set the locator explicitly, so use the default
856858# for this axis:
857- locator = self ._long_axis () .get_major_locator ()
859+ locator = self .long_axis .get_major_locator ()
858860if minorlocator is None :
859- minorlocator = self ._long_axis () .get_minor_locator ()
861+ minorlocator = self .long_axis .get_minor_locator ()
860862
861863if minorlocator is None :
862864minorlocator = ticker .NullLocator ()
863865
864866if formatter is None :
865- formatter = self ._long_axis () .get_major_formatter ()
867+ formatter = self .long_axis .get_major_formatter ()
866868
867869self ._locator = locator
868870self ._formatter = formatter
@@ -886,12 +888,12 @@ def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):
886888 pass *labels*. In other cases, please use `~.Axes.tick_params`.
887889 """
888890if np .iterable (ticks ):
889- self ._long_axis () .set_ticks (ticks ,labels = labels ,minor = minor ,
891+ self .long_axis .set_ticks (ticks ,labels = labels ,minor = minor ,
890892** kwargs )
891- self ._locator = self ._long_axis () .get_major_locator ()
893+ self ._locator = self .long_axis .get_major_locator ()
892894else :
893895self ._locator = ticks
894- self ._long_axis () .set_major_locator (self ._locator )
896+ self .long_axis .set_major_locator (self ._locator )
895897self .stale = True
896898
897899def get_ticks (self ,minor = False ):
@@ -904,9 +906,9 @@ def get_ticks(self, minor=False):
904906 if True return the minor ticks.
905907 """
906908if minor :
907- return self ._long_axis () .get_minorticklocs ()
909+ return self .long_axis .get_minorticklocs ()
908910else :
909- return self ._long_axis () .get_majorticklocs ()
911+ return self .long_axis .get_majorticklocs ()
910912
911913def set_ticklabels (self ,ticklabels ,* ,minor = False ,** kwargs ):
912914"""
@@ -941,7 +943,7 @@ def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
941943 **kwargs
942944 `.Text` properties for the labels.
943945 """
944- self ._long_axis () .set_ticklabels (ticklabels ,minor = minor ,** kwargs )
946+ self .long_axis .set_ticklabels (ticklabels ,minor = minor ,** kwargs )
945947
946948def minorticks_on (self ):
947949"""
@@ -953,7 +955,7 @@ def minorticks_on(self):
953955def minorticks_off (self ):
954956"""Turn the minor ticks of the colorbar off."""
955957self ._minorlocator = ticker .NullLocator ()
956- self ._long_axis () .set_minor_locator (self ._minorlocator )
958+ self .long_axis .set_minor_locator (self ._minorlocator )
957959
958960def set_label (self ,label ,* ,loc = None ,** kwargs ):
959961"""
@@ -1018,7 +1020,7 @@ def _set_scale(self, scale, **kwargs):
10181020 `matplotlib.scale.register_scale`. These scales can then also
10191021 be used here.
10201022 """
1021- self ._long_axis () ._set_axes_scale (scale ,** kwargs )
1023+ self .long_axis ._set_axes_scale (scale ,** kwargs )
10221024
10231025def remove (self ):
10241026"""
@@ -1290,20 +1292,14 @@ def _get_extension_lengths(self, frac, automin, automax, default=0.05):
12901292
12911293def _extend_lower (self ):
12921294"""Return whether the lower limit is open ended."""
1293- minmax = "max" if self ._long_axis () .get_inverted ()else "min"
1295+ minmax = "max" if self .long_axis .get_inverted ()else "min"
12941296return self .extend in ('both' ,minmax )
12951297
12961298def _extend_upper (self ):
12971299"""Return whether the upper limit is open ended."""
1298- minmax = "min" if self ._long_axis () .get_inverted ()else "max"
1300+ minmax = "min" if self .long_axis .get_inverted ()else "max"
12991301return self .extend in ('both' ,minmax )
13001302
1301- def _long_axis (self ):
1302- """Return the long axis"""
1303- if self .orientation == 'vertical' :
1304- return self .ax .yaxis
1305- return self .ax .xaxis
1306-
13071303def _short_axis (self ):
13081304"""Return the short axis"""
13091305if self .orientation == 'vertical' :