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]