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

Commita8c5557

Browse files
committed
Move the call to Formatter.set_locs into Formatter.format_ticks.
All calls to Formatter.set_locs occur before a call toFormatter.format_ticks (or its predecessor, a list of calls to`Formatter.__call__`); it was basically a bandaid around the fact thatall tick locations were needed to properly format an individual tick.Move the call to set_locs into format_ticks, with the intention to laterdeprecate set_locs.Convert a few more places to use format_ticks.
1 parent64c84b4 commita8c5557

File tree

7 files changed

+15
-21
lines changed

7 files changed

+15
-21
lines changed

‎doc/api/next_api_changes/2018-01-28-AL.rst

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@ New `Formatter.format_ticks` method
44
The `Formatter` class gained a new `~Formatter.format_ticks` method, which
55
takes the list of all tick locations as a single argument and returns the list
66
of all formatted values. It is called by the axis tick handling code and, by
7-
default, repeatedly calls `~Formatter.__call__`.
7+
default, first calls `~Formatter.set_locs` with all locations, then repeatedly
8+
calls `~Formatter.__call__` for each location.
89

9-
It is intended to be overridden by `Formatter` subclasses for which
10-
the formatting of a tick value depends on other tick values, such as
10+
Tick-handling code in the codebase that previously performed this sequence
11+
(`~Formatter.set_locs` followed by repeated `~Formatter.__call__`) have been
12+
updated to use `~Formatter.format_ticks`.
13+
14+
`~Formatter.format_tics` is intended to be overridden by `Formatter` subclasses
15+
for which the formatting of a tick value depends on other tick values, such as
1116
`ConciseDateFormatter`.

‎lib/matplotlib/axis.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -934,12 +934,10 @@ def iter_ticks(self):
934934
"""
935935
major_locs=self.major.locator()
936936
major_ticks=self.get_major_ticks(len(major_locs))
937-
self.major.formatter.set_locs(major_locs)
938937
major_labels=self.major.formatter.format_ticks(major_locs)
939938

940939
minor_locs=self.minor.locator()
941940
minor_ticks=self.get_minor_ticks(len(minor_locs))
942-
self.minor.formatter.set_locs(minor_locs)
943941
minor_labels=self.minor.formatter.format_ticks(minor_locs)
944942

945943
yieldfromzip(major_ticks,major_locs,major_labels)

‎lib/matplotlib/colorbar.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -788,7 +788,6 @@ def _ticker(self, locator, formatter):
788788
b=b[(b<=intv[1]+eps)& (b>=intv[0]-eps)]
789789
self._manual_tick_data_values=b
790790
ticks=self._locate(b)
791-
formatter.set_locs(b)
792791
ticklabels=formatter.format_ticks(b)
793792
offset_string=formatter.get_offset()
794793
returnticks,ticklabels,offset_string

‎lib/matplotlib/ticker.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,7 @@ def __call__(self, x, pos=None):
255255

256256
defformat_ticks(self,values):
257257
"""Return the tick labels for all the ticks at once."""
258+
self.set_locs(values)
258259
return [self(value,i)fori,valueinenumerate(values)]
259260

260261
defformat_data(self,value):

‎lib/mpl_toolkits/axisartist/axislines.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -225,12 +225,10 @@ def get_tick_iterators(self, axes):
225225

226226
major=self.axis.major
227227
majorLocs=major.locator()
228-
major.formatter.set_locs(majorLocs)
229228
majorLabels=major.formatter.format_ticks(majorLocs)
230229

231230
minor=self.axis.minor
232231
minorLocs=minor.locator()
233-
minor.formatter.set_locs(minorLocs)
234232
minorLabels=minor.formatter.format_ticks(minorLocs)
235233

236234
trans_tick=self.get_tick_transform(axes)

‎lib/mpl_toolkits/axisartist/grid_finder.py

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -291,11 +291,9 @@ def __init__(self, useMathText=True):
291291
def__call__(self,direction,factor,values):
292292
ifnotself._ignore_factor:
293293
iffactorisNone:
294-
factor=1.
295-
values= [v/factorforvinvalues]
296-
#values = [v for v in values]
297-
self._fmt.set_locs(values)
298-
return [self._fmt(v)forvinvalues]
294+
factor=1
295+
values= [v/factorforvinvalues]
296+
returnself._fmt.format_ticks(values)
299297

300298

301299
classDictFormatter(object):

‎lib/mpl_toolkits/mplot3d/axis3d.py

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,7 @@ def init3d(self):
135135

136136
defget_tick_positions(self):
137137
majorLocs=self.major.locator()
138-
self.major.formatter.set_locs(majorLocs)
139-
majorLabels= [self.major.formatter(val,i)
140-
fori,valinenumerate(majorLocs)]
138+
majorLabels=self.major.formatter.format_ticks(majorLocs)
141139
returnmajorLabels,majorLocs
142140

143141
defget_major_ticks(self,numticks=None):
@@ -236,11 +234,8 @@ def draw(self, renderer):
236234
locmin,locmax=locmax,locmin
237235

238236
# Rudimentary clipping
239-
majorLocs= [locforlocinmajorLocsif
240-
locmin<=loc<=locmax]
241-
self.major.formatter.set_locs(majorLocs)
242-
majorLabels= [self.major.formatter(val,i)
243-
fori,valinenumerate(majorLocs)]
237+
majorLocs= [locforlocinmajorLocsiflocmin<=loc<=locmax]
238+
majorLabels=self.major.format_ticks(majorLocs)
244239

245240
mins,maxs,centers,deltas,tc,highs=self._get_coord_info(renderer)
246241

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp