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

Commit9cf03c0

Browse files
authored
Merge pull request#22850 from timhoffm/get_tick-simplification
2 parents4e20f15 +120328f commit9cf03c0

File tree

2 files changed

+13
-29
lines changed

2 files changed

+13
-29
lines changed

‎lib/matplotlib/axis.py‎

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -635,6 +635,9 @@ class Axis(martist.Artist):
635635
The minor ticks.
636636
"""
637637
OFFSETTEXTPAD=3
638+
# The class used in _get_tick() to create tick instances. Must either be
639+
# overwritten in subclasses, or subclasses must reimplement _get_tick().
640+
_tick_class=None
638641

639642
def__str__(self):
640643
return"{}({},{})".format(
@@ -1437,7 +1440,12 @@ def get_ticks_direction(self, minor=False):
14371440

14381441
def_get_tick(self,major):
14391442
"""Return the default tick instance."""
1440-
raiseNotImplementedError('derived must override')
1443+
ifself._tick_classisNone:
1444+
raiseNotImplementedError(
1445+
f"The Axis subclass{self.__class__.__name__} must define "
1446+
"_tick_class or reimplement _get_tick()")
1447+
tick_kw=self._major_tick_kwifmajorelseself._minor_tick_kw
1448+
returnself._tick_class(self.axes,0,major=major,**tick_kw)
14411449

14421450
def_get_tick_label_size(self,axis_name):
14431451
"""
@@ -2133,6 +2141,7 @@ def setter(self, vmin, vmax, ignore=False):
21332141
classXAxis(Axis):
21342142
__name__='xaxis'
21352143
axis_name='x'#: Read-only name identifying the axis.
2144+
_tick_class=XTick
21362145

21372146
def__init__(self,*args,**kwargs):
21382147
super().__init__(*args,**kwargs)
@@ -2173,13 +2182,6 @@ def contains(self, mouseevent):
21732182
t<y<t+self.pickradius)
21742183
returninaxis, {}
21752184

2176-
def_get_tick(self,major):
2177-
ifmajor:
2178-
tick_kw=self._major_tick_kw
2179-
else:
2180-
tick_kw=self._minor_tick_kw
2181-
returnXTick(self.axes,0,major=major,**tick_kw)
2182-
21832185
defset_label_position(self,position):
21842186
"""
21852187
Set the label position (top or bottom)
@@ -2389,6 +2391,7 @@ def get_tick_space(self):
23892391
classYAxis(Axis):
23902392
__name__='yaxis'
23912393
axis_name='y'#: Read-only name identifying the axis.
2394+
_tick_class=YTick
23922395

23932396
def__init__(self,*args,**kwargs):
23942397
super().__init__(*args,**kwargs)
@@ -2431,13 +2434,6 @@ def contains(self, mouseevent):
24312434
r<x<r+self.pickradius)
24322435
returninaxis, {}
24332436

2434-
def_get_tick(self,major):
2435-
ifmajor:
2436-
tick_kw=self._major_tick_kw
2437-
else:
2438-
tick_kw=self._minor_tick_kw
2439-
returnYTick(self.axes,0,major=major,**tick_kw)
2440-
24412437
defset_label_position(self,position):
24422438
"""
24432439
Set the label position (left or right)

‎lib/matplotlib/projections/polar.py‎

Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -358,13 +358,7 @@ class ThetaAxis(maxis.XAxis):
358358
"""
359359
__name__='thetaaxis'
360360
axis_name='theta'#: Read-only name identifying the axis.
361-
362-
def_get_tick(self,major):
363-
ifmajor:
364-
tick_kw=self._major_tick_kw
365-
else:
366-
tick_kw=self._minor_tick_kw
367-
returnThetaTick(self.axes,0,major=major,**tick_kw)
361+
_tick_class=ThetaTick
368362

369363
def_wrap_locator_formatter(self):
370364
self.set_major_locator(ThetaLocator(self.get_major_locator()))
@@ -653,18 +647,12 @@ class RadialAxis(maxis.YAxis):
653647
"""
654648
__name__='radialaxis'
655649
axis_name='radius'#: Read-only name identifying the axis.
650+
_tick_class=RadialTick
656651

657652
def__init__(self,*args,**kwargs):
658653
super().__init__(*args,**kwargs)
659654
self.sticky_edges.y.append(0)
660655

661-
def_get_tick(self,major):
662-
ifmajor:
663-
tick_kw=self._major_tick_kw
664-
else:
665-
tick_kw=self._minor_tick_kw
666-
returnRadialTick(self.axes,0,major=major,**tick_kw)
667-
668656
def_wrap_locator_formatter(self):
669657
self.set_major_locator(RadialLocator(self.get_major_locator(),
670658
self.axes))

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp