FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Move the call to Formatter.set_locs into Formatter.format_ticks. by anntzer · Pull Request #13323 · matplotlib/matplotlib · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .py  (6) .rst  (1) All 2 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
13 changes: 9 additions & 4 deletions doc/api/next_api_changes/2018-01-28-AL.rst
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,13 @@ New `Formatter.format_ticks` method
The `Formatter` class gained a new `~Formatter.format_ticks` method, which
takes the list of all tick locations as a single argument and returns the list
of all formatted values. It is called by the axis tick handling code and, by
default, repeatedly calls `~Formatter.__call__`.
default, first calls `~Formatter.set_locs` with all locations, then repeatedly
calls `~Formatter.__call__` for each location.

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

`~Formatter.format_ticks` is intended to be overridden by `Formatter`
subclasses for which the formatting of a tick value depends on other tick
values, such as `ConciseDateFormatter`.
2 changes: 0 additions & 2 deletions lib/matplotlib/axis.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -934,12 +934,10 @@ def iter_ticks(self):
"""
major_locs = self.major.locator()
major_ticks = self.get_major_ticks(len(major_locs))
self.major.formatter.set_locs(major_locs)
major_labels = self.major.formatter.format_ticks(major_locs)

minor_locs = self.minor.locator()
minor_ticks = self.get_minor_ticks(len(minor_locs))
self.minor.formatter.set_locs(minor_locs)
minor_labels = self.minor.formatter.format_ticks(minor_locs)

yield from zip(major_ticks, major_locs, major_labels)
Expand Down
1 change: 0 additions & 1 deletion lib/matplotlib/colorbar.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -788,7 +788,6 @@ def _ticker(self, locator, formatter):
b = b[(b <= intv[1] + eps) & (b >= intv[0] - eps)]
self._manual_tick_data_values = b
ticks = self._locate(b)
formatter.set_locs(b)
ticklabels = formatter.format_ticks(b)
offset_string = formatter.get_offset()
return ticks, ticklabels, offset_string
Expand Down
1 change: 1 addition & 0 deletions lib/matplotlib/ticker.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ def __call__(self, x, pos=None):

def format_ticks(self, values):
"""Return the tick labels for all the ticks at once."""
self.set_locs(values)
return [self(value, i) for i, value in enumerate(values)]

def format_data(self, value):
Expand Down
2 changes: 0 additions & 2 deletions lib/mpl_toolkits/axisartist/axislines.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -225,12 +225,10 @@ def get_tick_iterators(self, axes):

major = self.axis.major
majorLocs = major.locator()
major.formatter.set_locs(majorLocs)
majorLabels = major.formatter.format_ticks(majorLocs)

minor = self.axis.minor
minorLocs = minor.locator()
minor.formatter.set_locs(minorLocs)
minorLabels = minor.formatter.format_ticks(minorLocs)

trans_tick = self.get_tick_transform(axes)
Expand Down
8 changes: 3 additions & 5 deletions lib/mpl_toolkits/axisartist/grid_finder.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -291,11 +291,9 @@ def __init__(self, useMathText=True):
def __call__(self, direction, factor, values):
if not self._ignore_factor:
if factor is None:
factor = 1.
values = [v/factor for v in values]
#values = [v for v in values]
self._fmt.set_locs(values)
return [self._fmt(v) for v in values]
factor = 1
values = [v / factor for v in values]
return self._fmt.format_ticks(values)


class DictFormatter(object):
Expand Down
11 changes: 3 additions & 8 deletions lib/mpl_toolkits/mplot3d/axis3d.py
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -135,9 +135,7 @@ def init3d(self):

def get_tick_positions(self):
majorLocs = self.major.locator()
self.major.formatter.set_locs(majorLocs)
majorLabels = [self.major.formatter(val, i)
for i, val in enumerate(majorLocs)]
majorLabels = self.major.formatter.format_ticks(majorLocs)
return majorLabels, majorLocs

def get_major_ticks(self, numticks=None):
Expand Down Expand Up @@ -236,11 +234,8 @@ def draw(self, renderer):
locmin, locmax = locmax, locmin

# Rudimentary clipping
majorLocs = [loc for loc in majorLocs if
locmin <= loc <= locmax]
self.major.formatter.set_locs(majorLocs)
majorLabels = [self.major.formatter(val, i)
for i, val in enumerate(majorLocs)]
majorLocs = [loc for loc in majorLocs if locmin <= loc <= locmax]
majorLabels = self.major.formatter.format_ticks(majorLocs)

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

Expand Down

Back | FazBrowse Home | New Git URL