From c0803f0d18fc19203950238aa2f9a0baaa98af15 Mon Sep 17 00:00:00 2001 From: Eric Firing Date: Tue, 25 Aug 2015 09:02:00 -1000 Subject: [PATCH] BUG: in ScalarFormatter, handle two identical locations; closes #4761 --- lib/matplotlib/ticker.py | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index c3bc178f8865..586373468f0f 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -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]