diff --git a/lib/matplotlib/tests/test_colors.py b/lib/matplotlib/tests/test_colors.py index b269157c05b5..7f67d0694fc2 100644 --- a/lib/matplotlib/tests/test_colors.py +++ b/lib/matplotlib/tests/test_colors.py @@ -247,6 +247,18 @@ def test_SymLogNorm_colorbar(): plt.close(fig) +def test_SymLogNorm_single_zero(): + """ + Test SymLogNorm to ensure it is not adding sub-ticks to zero label + """ + fig = plt.figure() + norm = mcolors.SymLogNorm(1e-5, vmin=-1, vmax=1) + cbar = mcolorbar.ColorbarBase(fig.add_subplot(111), norm=norm) + ticks = cbar.get_ticks() + assert sum(ticks == 0) == 1 + plt.close(fig) + + def _inverse_tester(norm_instance, vals): """ Checks if the inverse of the given normalization is working. diff --git a/lib/matplotlib/ticker.py b/lib/matplotlib/ticker.py index dc133370e567..c91e78b6ae85 100644 --- a/lib/matplotlib/ticker.py +++ b/lib/matplotlib/ticker.py @@ -2346,7 +2346,10 @@ def get_log_range(lo, hi): if len(subs) > 1 or subs[0] != 1.0: ticklocs = [] for decade in decades: - ticklocs.extend(subs * decade) + if decade == 0: + ticklocs.append(decade) + else: + ticklocs.extend(subs * decade) else: ticklocs = decades pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy