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

Commit825f518

Browse files
authored
Merge pull request#18645 from anntzer/cbar
Simplify Colorbar.set_label, inline Colorbar._edges.
2 parents80c40b8 +e97bb70 commit825f518

File tree

1 file changed

+5
-31
lines changed

1 file changed

+5
-31
lines changed

‎lib/matplotlib/colorbar.py

Lines changed: 5 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -766,39 +766,12 @@ def set_label(self, label, *, loc=None, **kwargs):
766766
`~.Axes.set_ylabel`.
767767
Supported keywords are *labelpad* and `.Text` properties.
768768
"""
769-
_pos_xy='y'ifself.orientation=='vertical'else'x'
770-
_protected_kw= [_pos_xy,'horizontalalignment','ha']
771-
ifany([kinkwargsforkin_protected_kw]):
772-
iflocisnotNone:
773-
raiseTypeError(f'Specifying *loc* is disallowed when any of '
774-
f'its corresponding low level keyword '
775-
f'arguments{_protected_kw} are also supplied')
776-
loc='center'
769+
ifself.orientation=="vertical":
770+
self.ax.set_ylabel(label,loc=loc,**kwargs)
777771
else:
778-
iflocisNone:
779-
loc=mpl.rcParams['%saxis.labellocation'%_pos_xy]
780-
ifself.orientation=='vertical':
781-
_api.check_in_list(('bottom','center','top'),loc=loc)
782-
else:
783-
_api.check_in_list(('left','center','right'),loc=loc)
784-
iflocin ['right','top']:
785-
kwargs[_pos_xy]=1.
786-
kwargs['horizontalalignment']='right'
787-
eliflocin ['left','bottom']:
788-
kwargs[_pos_xy]=0.
789-
kwargs['horizontalalignment']='left'
790-
ifself.orientation=='vertical':
791-
self.ax.set_ylabel(label,**kwargs)
792-
else:
793-
self.ax.set_xlabel(label,**kwargs)
772+
self.ax.set_xlabel(label,loc=loc,**kwargs)
794773
self.stale=True
795774

796-
def_edges(self,X,Y):
797-
"""Return the separator line segments; helper for _add_solids."""
798-
# Using the non-array form of these line segments is much
799-
# simpler than making them into arrays.
800-
return [list(zip(X[i],Y[i]))foriinrange(1,len(X)-1)]
801-
802775
def_add_solids(self,X,Y,C):
803776
"""Draw the colors; optionally add separators."""
804777
# Cleanup previously set artists.
@@ -814,7 +787,8 @@ def _add_solids(self, X, Y, C):
814787
self._add_solids_patches(X,Y,C,mappable)
815788
else:
816789
self._add_solids_pcolormesh(X,Y,C)
817-
self.dividers.set_segments(self._edges(X,Y)ifself.drawedgeselse [])
790+
self.dividers.set_segments(
791+
np.dstack([X,Y])[1:-1]ifself.drawedgeselse [])
818792

819793
def_add_solids_pcolormesh(self,X,Y,C):
820794
_log.debug('Setting pcolormesh')

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp