Skip to content

Commit

Permalink
Merge pull request #4988 from efiring/ScalarFormatter_zero
Browse files Browse the repository at this point in the history
BUG: in ScalarFormatter, handle two identical locations

closes #4761
  • Loading branch information
tacaswell committed Aug 26, 2015
2 parents 6e4e3a2 + c0803f0 commit 58cba1f
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/matplotlib/ticker.py
Expand Up @@ -585,6 +585,12 @@ def _set_format(self, vmin, vmax):
_locs = self.locs
locs = (np.asarray(_locs) - self.offset) / 10. ** self.orderOfMagnitude
loc_range = np.ptp(locs)
# Curvilinear coordinates can yield two identical points.
if loc_range == 0:
loc_range = np.max(np.abs(locs))
# Both points might be zero.
if loc_range == 0:
loc_range = 1
if len(self.locs) < 2:
# We needed the end points only for the loc_range calculation.
locs = locs[:-2]
Expand Down

0 comments on commit 58cba1f

Please sign in to comment.