Skip to content

Navigation Menu

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit fecdb54

Browse filesBrowse files
committed
MNT: remove _long_axis
1 parent 58e1912 commit fecdb54
Copy full SHA for fecdb54

File tree

1 file changed

+31
-35
lines changed
Filter options

1 file changed

+31
-35
lines changed

‎lib/matplotlib/colorbar.py

Copy file name to clipboardExpand all lines: lib/matplotlib/colorbar.py
+31-35Lines changed: 31 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -433,46 +433,48 @@ def __init__(self, ax, mappable=None, *, cmap=None,
433433
@property
434434
def 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
439441
def 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
444446
def locator(self, loc):
445-
self._long_axis().set_major_locator(loc)
447+
self.long_axis.set_major_locator(loc)
446448
self._locator = loc
447449

448450
@property
449451
def 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
454456
def minorlocator(self, loc):
455-
self._long_axis().set_minor_locator(loc)
457+
self.long_axis.set_minor_locator(loc)
456458
self._minorlocator = loc
457459

458460
@property
459461
def 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
464466
def formatter(self, fmt):
465-
self._long_axis().set_major_formatter(fmt)
467+
self.long_axis.set_major_formatter(fmt)
466468
self._formatter = fmt
467469

468470
@property
469471
def 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
474476
def minorformatter(self, fmt):
475-
self._long_axis().set_minor_formatter(fmt)
477+
self.long_axis.set_minor_formatter(fmt)
476478
self._minorformatter = fmt
477479

478480
def _cbar_cla(self):
@@ -531,7 +533,7 @@ def _draw_all(self):
531533
else:
532534
if mpl.rcParams['xtick.minor.visible']:
533535
self.minorticks_on()
534-
self._long_axis().set(label_position=self.ticklocation,
536+
self.long_axis.set(label_position=self.ticklocation,
535537
ticks_position=self.ticklocation)
536538
self._short_axis().set_ticks([])
537539
self._short_axis().set_ticks([], minor=True)
@@ -550,7 +552,7 @@ def _draw_all(self):
550552
# also adds the outline path to self.outline spine:
551553
self._do_extends()
552554
lower, 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
555557
lower, upper = upper, lower
556558
if self.orientation == 'vertical':
@@ -691,7 +693,7 @@ def _do_extends(self, ax=None):
691693
if self.orientation == 'horizontal':
692694
xy = 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
695697
color = self.cmap(self.norm(self._values[val]))
696698
patch = mpatches.PathPatch(
697699
mpath.Path(xy), facecolor=color, alpha=self.alpha,
@@ -715,7 +717,7 @@ def _do_extends(self, ax=None):
715717
if self.orientation == 'horizontal':
716718
xy = 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
719721
color = self.cmap(self.norm(self._values[val]))
720722
hatch_idx = len(self._y) - 1
721723
patch = mpatches.PathPatch(
@@ -817,9 +819,9 @@ def update_ticks(self):
817819
"""
818820
# Get the locator and formatter; defaults to self._locator if not None.
819821
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)
823825

824826
def _get_ticker_locator_formatter(self):
825827
"""
@@ -854,15 +856,15 @@ def _get_ticker_locator_formatter(self):
854856
if 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()
858860
if minorlocator is None:
859-
minorlocator = self._long_axis().get_minor_locator()
861+
minorlocator = self.long_axis.get_minor_locator()
860862

861863
if minorlocator is None:
862864
minorlocator = ticker.NullLocator()
863865

864866
if formatter is None:
865-
formatter = self._long_axis().get_major_formatter()
867+
formatter = self.long_axis.get_major_formatter()
866868

867869
self._locator = locator
868870
self._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
"""
888890
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,
890892
**kwargs)
891-
self._locator = self._long_axis().get_major_locator()
893+
self._locator = self.long_axis.get_major_locator()
892894
else:
893895
self._locator = ticks
894-
self._long_axis().set_major_locator(self._locator)
896+
self.long_axis.set_major_locator(self._locator)
895897
self.stale = True
896898

897899
def get_ticks(self, minor=False):
@@ -904,9 +906,9 @@ def get_ticks(self, minor=False):
904906
if True return the minor ticks.
905907
"""
906908
if minor:
907-
return self._long_axis().get_minorticklocs()
909+
return self.long_axis.get_minorticklocs()
908910
else:
909-
return self._long_axis().get_majorticklocs()
911+
return self.long_axis.get_majorticklocs()
910912

911913
def 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

946948
def minorticks_on(self):
947949
"""
@@ -953,7 +955,7 @@ def minorticks_on(self):
953955
def minorticks_off(self):
954956
"""Turn the minor ticks of the colorbar off."""
955957
self._minorlocator = ticker.NullLocator()
956-
self._long_axis().set_minor_locator(self._minorlocator)
958+
self.long_axis.set_minor_locator(self._minorlocator)
957959

958960
def 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

10231025
def remove(self):
10241026
"""
@@ -1290,20 +1292,14 @@ def _get_extension_lengths(self, frac, automin, automax, default=0.05):
12901292

12911293
def _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"
12941296
return self.extend in ('both', minmax)
12951297

12961298
def _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"
12991301
return 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-
13071303
def _short_axis(self):
13081304
"""Return the short axis"""
13091305
if self.orientation == 'vertical':

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.