From 7fe5e4e686da17e5b19fb13ddf4e51d1c63121ea Mon Sep 17 00:00:00 2001 From: Rob Harrigan Date: Sat, 30 Dec 2017 09:27:42 -0600 Subject: [PATCH 1/2] prevent subticks from being added to zero decade --- lib/matplotlib/ticker.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) 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 From e9af134acbecb3727bc95e5050b8a9db66bd223f Mon Sep 17 00:00:00 2001 From: Rob Harrigan Date: Tue, 2 Jan 2018 07:56:51 -0600 Subject: [PATCH 2/2] adding test for SymLogNorm single zero fix --- lib/matplotlib/tests/test_colors.py | 12 ++++++++++++ 1 file changed, 12 insertions(+) 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. 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