diff --git a/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf b/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf index d3a109773d24..37f6d6131652 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf and b/lib/matplotlib/tests/baseline_images/test_axes/symlog.pdf differ diff --git a/lib/matplotlib/tests/baseline_images/test_axes/symlog2.pdf b/lib/matplotlib/tests/baseline_images/test_axes/symlog2.pdf index d5b93ce3bfbe..b701693481c0 100644 Binary files a/lib/matplotlib/tests/baseline_images/test_axes/symlog2.pdf and b/lib/matplotlib/tests/baseline_images/test_axes/symlog2.pdf differ diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index b257adb5237e..b196d3bf6251 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2408,33 +2408,24 @@ def tick_values(self, vmin, vmax): # # "simple" mode is when the range falls entirely within (-t, # t) -- it should just display (vmin, 0, vmax) + if -linthresh < vmin < vmax < linthresh: + return [vmin, vmax] - # Determine which of the three ranges we have - has_a = has_b = has_c = False - if vmin < -linthresh: - has_a = True - if vmax > -linthresh: - has_b = True - if vmax > linthresh: - has_c = True - elif vmin < 0: - if vmax > 0: - has_b = True - if vmax > linthresh: - has_c = True - else: - return [vmin, vmax] - elif vmin < linthresh: - if vmax > linthresh: - has_b = True - has_c = True - else: - return [vmin, vmax] + has_a = (vmin < -linthresh) + has_c = (vmax > linthresh) + + if (has_a and vmax > -linthresh) or (has_c and vmin < linthresh): + has_b = True else: - has_c = True + has_b = False def get_log_range(lo, hi): - lo = np.floor(np.log(lo) / np.log(base)) + """ + Get the first integer exponents above *lo* and *hi*. These are + chosen to be above in both cases to avoid encroaching range b for + lo, and to extend out of ranges a or c for hi. + """ + lo = np.ceil(np.log(lo) / np.log(base)) hi = np.ceil(np.log(hi) / np.log(base)) return lo, hi