Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

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

Sign up
Appearance settings

Commitfecdb54

Browse files
committed
MNT: remove _long_axis
1 parent58e1912 commitfecdb54

File tree

1 file changed

+31
-35
lines changed

1 file changed

+31
-35
lines changed

‎lib/matplotlib/colorbar.py‎

Lines 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
deflong_axis(self):
435435
"""Axis that has decorations (ticks, etc) on it."""
436-
returnself._long_axis()
436+
ifself.orientation=='vertical':
437+
returnself.ax.yaxis
438+
returnself.ax.xaxis
437439

438440
@property
439441
deflocator(self):
440442
"""Major tick `.Locator` for the colorbar."""
441-
returnself._long_axis().get_major_locator()
443+
returnself.long_axis.get_major_locator()
442444

443445
@locator.setter
444446
deflocator(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
defminorlocator(self):
450452
"""Minor tick `.Locator` for the colorbar."""
451-
returnself._long_axis().get_minor_locator()
453+
returnself.long_axis.get_minor_locator()
452454

453455
@minorlocator.setter
454456
defminorlocator(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
defformatter(self):
460462
"""Major tick label `.Formatter` for the colorbar."""
461-
returnself._long_axis().get_major_formatter()
463+
returnself.long_axis.get_major_formatter()
462464

463465
@formatter.setter
464466
defformatter(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
defminorformatter(self):
470472
"""Minor tick `.Formatter` for the colorbar."""
471-
returnself._long_axis().get_minor_formatter()
473+
returnself.long_axis.get_minor_formatter()
472474

473475
@minorformatter.setter
474476
defminorformatter(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
ifmpl.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-
ifself._long_axis().get_inverted():
555+
ifself.long_axis.get_inverted():
554556
# If the axis is inverted, we need to swap the vmin/vmax
555557
lower,upper=upper,lower
556558
ifself.orientation=='vertical':
@@ -691,7 +693,7 @@ def _do_extends(self, ax=None):
691693
ifself.orientation=='horizontal':
692694
xy=xy[:, ::-1]
693695
# add the patch
694-
val=-1ifself._long_axis().get_inverted()else0
696+
val=-1ifself.long_axis.get_inverted()else0
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
ifself.orientation=='horizontal':
716718
xy=xy[:, ::-1]
717719
# add the patch
718-
val=0ifself._long_axis().get_inverted()else-1
720+
val=0ifself.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
iflocatorisNone:
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
ifminorlocatorisNone:
859-
minorlocator=self._long_axis().get_minor_locator()
861+
minorlocator=self.long_axis.get_minor_locator()
860862

861863
ifminorlocatorisNone:
862864
minorlocator=ticker.NullLocator()
863865

864866
ifformatterisNone:
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
ifnp.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
defget_ticks(self,minor=False):
@@ -904,9 +906,9 @@ def get_ticks(self, minor=False):
904906
if True return the minor ticks.
905907
"""
906908
ifminor:
907-
returnself._long_axis().get_minorticklocs()
909+
returnself.long_axis.get_minorticklocs()
908910
else:
909-
returnself._long_axis().get_majorticklocs()
911+
returnself.long_axis.get_majorticklocs()
910912

911913
defset_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
defminorticks_on(self):
947949
"""
@@ -953,7 +955,7 @@ def minorticks_on(self):
953955
defminorticks_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
defset_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
defremove(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"ifself._long_axis().get_inverted()else"min"
1295+
minmax="max"ifself.long_axis.get_inverted()else"min"
12941296
returnself.extendin ('both',minmax)
12951297

12961298
def_extend_upper(self):
12971299
"""Return whether the upper limit is open ended."""
1298-
minmax="min"ifself._long_axis().get_inverted()else"max"
1300+
minmax="min"ifself.long_axis.get_inverted()else"max"
12991301
returnself.extendin ('both',minmax)
13001302

1301-
def_long_axis(self):
1302-
"""Return the long axis"""
1303-
ifself.orientation=='vertical':
1304-
returnself.ax.yaxis
1305-
returnself.ax.xaxis
1306-
13071303
def_short_axis(self):
13081304
"""Return the short axis"""
13091305
ifself.orientation=='vertical':

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp