@@ -433,46 +433,48 @@ def __init__(self, ax, mappable=None, *, cmap=None,
433
433
@property
434
434
def long_axis (self ):
435
435
"""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
437
439
438
440
@property
439
441
def locator (self ):
440
442
"""Major tick `.Locator` for the colorbar."""
441
- return self ._long_axis () .get_major_locator ()
443
+ return self .long_axis .get_major_locator ()
442
444
443
445
@locator .setter
444
446
def locator (self , loc ):
445
- self ._long_axis () .set_major_locator (loc )
447
+ self .long_axis .set_major_locator (loc )
446
448
self ._locator = loc
447
449
448
450
@property
449
451
def minorlocator (self ):
450
452
"""Minor tick `.Locator` for the colorbar."""
451
- return self ._long_axis () .get_minor_locator ()
453
+ return self .long_axis .get_minor_locator ()
452
454
453
455
@minorlocator .setter
454
456
def minorlocator (self , loc ):
455
- self ._long_axis () .set_minor_locator (loc )
457
+ self .long_axis .set_minor_locator (loc )
456
458
self ._minorlocator = loc
457
459
458
460
@property
459
461
def formatter (self ):
460
462
"""Major tick label `.Formatter` for the colorbar."""
461
- return self ._long_axis () .get_major_formatter ()
463
+ return self .long_axis .get_major_formatter ()
462
464
463
465
@formatter .setter
464
466
def formatter (self , fmt ):
465
- self ._long_axis () .set_major_formatter (fmt )
467
+ self .long_axis .set_major_formatter (fmt )
466
468
self ._formatter = fmt
467
469
468
470
@property
469
471
def minorformatter (self ):
470
472
"""Minor tick `.Formatter` for the colorbar."""
471
- return self ._long_axis () .get_minor_formatter ()
473
+ return self .long_axis .get_minor_formatter ()
472
474
473
475
@minorformatter .setter
474
476
def minorformatter (self , fmt ):
475
- self ._long_axis () .set_minor_formatter (fmt )
477
+ self .long_axis .set_minor_formatter (fmt )
476
478
self ._minorformatter = fmt
477
479
478
480
def _cbar_cla (self ):
@@ -531,7 +533,7 @@ def _draw_all(self):
531
533
else :
532
534
if mpl .rcParams ['xtick.minor.visible' ]:
533
535
self .minorticks_on ()
534
- self ._long_axis () .set (label_position = self .ticklocation ,
536
+ self .long_axis .set (label_position = self .ticklocation ,
535
537
ticks_position = self .ticklocation )
536
538
self ._short_axis ().set_ticks ([])
537
539
self ._short_axis ().set_ticks ([], minor = True )
@@ -550,7 +552,7 @@ def _draw_all(self):
550
552
# also adds the outline path to self.outline spine:
551
553
self ._do_extends ()
552
554
lower , upper = self .vmin , self .vmax
553
- if self ._long_axis () .get_inverted ():
555
+ if self .long_axis .get_inverted ():
554
556
# If the axis is inverted, we need to swap the vmin/vmax
555
557
lower , upper = upper , lower
556
558
if self .orientation == 'vertical' :
@@ -691,7 +693,7 @@ def _do_extends(self, ax=None):
691
693
if self .orientation == 'horizontal' :
692
694
xy = xy [:, ::- 1 ]
693
695
# 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
695
697
color = self .cmap (self .norm (self ._values [val ]))
696
698
patch = mpatches .PathPatch (
697
699
mpath .Path (xy ), facecolor = color , alpha = self .alpha ,
@@ -715,7 +717,7 @@ def _do_extends(self, ax=None):
715
717
if self .orientation == 'horizontal' :
716
718
xy = xy [:, ::- 1 ]
717
719
# 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
719
721
color = self .cmap (self .norm (self ._values [val ]))
720
722
hatch_idx = len (self ._y ) - 1
721
723
patch = mpatches .PathPatch (
@@ -817,9 +819,9 @@ def update_ticks(self):
817
819
"""
818
820
# Get the locator and formatter; defaults to self._locator if not None.
819
821
self ._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 )
823
825
824
826
def _get_ticker_locator_formatter (self ):
825
827
"""
@@ -854,15 +856,15 @@ def _get_ticker_locator_formatter(self):
854
856
if locator is None :
855
857
# we haven't set the locator explicitly, so use the default
856
858
# for this axis:
857
- locator = self ._long_axis () .get_major_locator ()
859
+ locator = self .long_axis .get_major_locator ()
858
860
if minorlocator is None :
859
- minorlocator = self ._long_axis () .get_minor_locator ()
861
+ minorlocator = self .long_axis .get_minor_locator ()
860
862
861
863
if minorlocator is None :
862
864
minorlocator = ticker .NullLocator ()
863
865
864
866
if formatter is None :
865
- formatter = self ._long_axis () .get_major_formatter ()
867
+ formatter = self .long_axis .get_major_formatter ()
866
868
867
869
self ._locator = locator
868
870
self ._formatter = formatter
@@ -886,12 +888,12 @@ def set_ticks(self, ticks, *, labels=None, minor=False, **kwargs):
886
888
pass *labels*. In other cases, please use `~.Axes.tick_params`.
887
889
"""
888
890
if 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 ,
890
892
** kwargs )
891
- self ._locator = self ._long_axis () .get_major_locator ()
893
+ self ._locator = self .long_axis .get_major_locator ()
892
894
else :
893
895
self ._locator = ticks
894
- self ._long_axis () .set_major_locator (self ._locator )
896
+ self .long_axis .set_major_locator (self ._locator )
895
897
self .stale = True
896
898
897
899
def get_ticks (self , minor = False ):
@@ -904,9 +906,9 @@ def get_ticks(self, minor=False):
904
906
if True return the minor ticks.
905
907
"""
906
908
if minor :
907
- return self ._long_axis () .get_minorticklocs ()
909
+ return self .long_axis .get_minorticklocs ()
908
910
else :
909
- return self ._long_axis () .get_majorticklocs ()
911
+ return self .long_axis .get_majorticklocs ()
910
912
911
913
def set_ticklabels (self , ticklabels , * , minor = False , ** kwargs ):
912
914
"""
@@ -941,7 +943,7 @@ def set_ticklabels(self, ticklabels, *, minor=False, **kwargs):
941
943
**kwargs
942
944
`.Text` properties for the labels.
943
945
"""
944
- self ._long_axis () .set_ticklabels (ticklabels , minor = minor , ** kwargs )
946
+ self .long_axis .set_ticklabels (ticklabels , minor = minor , ** kwargs )
945
947
946
948
def minorticks_on (self ):
947
949
"""
@@ -953,7 +955,7 @@ def minorticks_on(self):
953
955
def minorticks_off (self ):
954
956
"""Turn the minor ticks of the colorbar off."""
955
957
self ._minorlocator = ticker .NullLocator ()
956
- self ._long_axis () .set_minor_locator (self ._minorlocator )
958
+ self .long_axis .set_minor_locator (self ._minorlocator )
957
959
958
960
def set_label (self , label , * , loc = None , ** kwargs ):
959
961
"""
@@ -1018,7 +1020,7 @@ def _set_scale(self, scale, **kwargs):
1018
1020
`matplotlib.scale.register_scale`. These scales can then also
1019
1021
be used here.
1020
1022
"""
1021
- self ._long_axis () ._set_axes_scale (scale , ** kwargs )
1023
+ self .long_axis ._set_axes_scale (scale , ** kwargs )
1022
1024
1023
1025
def remove (self ):
1024
1026
"""
@@ -1290,20 +1292,14 @@ def _get_extension_lengths(self, frac, automin, automax, default=0.05):
1290
1292
1291
1293
def _extend_lower (self ):
1292
1294
"""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"
1294
1296
return self .extend in ('both' , minmax )
1295
1297
1296
1298
def _extend_upper (self ):
1297
1299
"""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"
1299
1301
return self .extend in ('both' , minmax )
1300
1302
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
-
1307
1303
def _short_axis (self ):
1308
1304
"""Return the short axis"""
1309
1305
if self .orientation == 'vertical' :
0 commit comments