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

Commit38da016

Browse files
authored
Merge pull request#15606 from anntzer/locator-refresh
Simplify OldAutoLocator and AutoDateLocator.
2 parents3e6c5d0 +1f53c6b commit38da016

File tree

2 files changed

+14
-32
lines changed

2 files changed

+14
-32
lines changed

‎lib/matplotlib/dates.py

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1220,7 +1220,6 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
12201220
at 6 hour intervals.
12211221
"""
12221222
DateLocator.__init__(self,tz)
1223-
self._locator=YearLocator(tz=tz)
12241223
self._freq=YEARLY
12251224
self._freqs= [YEARLY,MONTHLY,DAILY,HOURLY,MINUTELY,
12261225
SECONDLY,MICROSECONDLY]
@@ -1258,9 +1257,10 @@ def __init__(self, tz=None, minticks=5, maxticks=None,
12581257
range(0,24),range(0,60),range(0,60),None]
12591258

12601259
def__call__(self):
1261-
"""Return the locations of the ticks."""
1262-
self.refresh()
1263-
returnself._locator()
1260+
# docstring inherited
1261+
dmin,dmax=self.viewlim_to_dt()
1262+
locator=self.get_locator(dmin,dmax)
1263+
returnlocator()
12641264

12651265
deftick_values(self,vmin,vmax):
12661266
returnself.get_locator(vmin,vmax).tick_values(vmin,vmax)
@@ -1279,15 +1279,6 @@ def nonsingular(self, vmin, vmax):
12791279
vmax=vmax+DAYS_PER_YEAR*2
12801280
returnvmin,vmax
12811281

1282-
defset_axis(self,axis):
1283-
DateLocator.set_axis(self,axis)
1284-
self._locator.set_axis(axis)
1285-
1286-
defrefresh(self):
1287-
# docstring inherited
1288-
dmin,dmax=self.viewlim_to_dt()
1289-
self._locator=self.get_locator(dmin,dmax)
1290-
12911282
def_get_unit(self):
12921283
ifself._freqin [MICROSECONDLY]:
12931284
return1./MUSECONDS_PER_DAY
@@ -1298,8 +1289,7 @@ def _get_unit(self):
12981289
defautoscale(self):
12991290
"""Try to choose the view limits intelligently."""
13001291
dmin,dmax=self.datalim_to_dt()
1301-
self._locator=self.get_locator(dmin,dmax)
1302-
returnself._locator.autoscale()
1292+
returnself.get_locator(dmin,dmax).autoscale()
13031293

13041294
defget_locator(self,dmin,dmax):
13051295
"""Pick the best locator based on a distance."""

‎lib/matplotlib/ticker.py

Lines changed: 9 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -2816,33 +2816,25 @@ class OldAutoLocator(Locator):
28162816
"""
28172817
On autoscale this class picks the best MultipleLocator to set the
28182818
view limits and the tick locs.
2819-
28202819
"""
2821-
def__init__(self):
2822-
self._locator=LinearLocator()
28232820

28242821
def__call__(self):
2825-
"""Return the locations of the ticks."""
2826-
self.refresh()
2827-
returnself.raise_if_exceeds(self._locator())
2828-
2829-
deftick_values(self,vmin,vmax):
2830-
raiseNotImplementedError('Cannot get tick locations for a '
2831-
'%s type.'%type(self))
2832-
2833-
defrefresh(self):
28342822
# docstring inherited
28352823
vmin,vmax=self.axis.get_view_interval()
28362824
vmin,vmax=mtransforms.nonsingular(vmin,vmax,expander=0.05)
28372825
d=abs(vmax-vmin)
2838-
self._locator=self.get_locator(d)
2826+
locator=self.get_locator(d)
2827+
returnself.raise_if_exceeds(locator())
28392828

2840-
defview_limits(self,vmin,vmax):
2841-
"""Try to choose the view limits intelligently."""
2829+
deftick_values(self,vmin,vmax):
2830+
raiseNotImplementedError('Cannot get tick locations for a '
2831+
'%s type.'%type(self))
28422832

2833+
defview_limits(self,vmin,vmax):
2834+
# docstring inherited
28432835
d=abs(vmax-vmin)
2844-
self._locator=self.get_locator(d)
2845-
returnself._locator.view_limits(vmin,vmax)
2836+
locator=self.get_locator(d)
2837+
returnlocator.view_limits(vmin,vmax)
28462838

28472839
defget_locator(self,d):
28482840
"""Pick the best locator based on a distance *d*."""

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp