Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 58a8334

Browse files
authored
Merge pull request #6780 from Salganos/Salganos-SymLogNorm
ENH: Call _transform_vmin_vmax during SymLogNorm.__init__
2 parents c34ddc4 + 3ec7376 commit 58a8334

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

lib/matplotlib/colors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1060,6 +1060,8 @@ def __init__(self, linthresh, linscale=1.0,
10601060
Normalize.__init__(self, vmin, vmax, clip)
10611061
self.linthresh = float(linthresh)
10621062
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
1063+
if vmin is not None and vmax is not None:
1064+
self._transform_vmin_vmax()
10631065

10641066
def __call__(self, value, clip=None):
10651067
if clip is None:

lib/matplotlib/tests/test_colors.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import matplotlib
2323
import matplotlib.colors as mcolors
2424
import matplotlib.cm as cm
25+
import matplotlib.colorbar as mcolorbar
2526
import matplotlib.cbook as cbook
2627
import matplotlib.pyplot as plt
2728
from matplotlib.testing.decorators import (image_comparison,
@@ -232,6 +233,17 @@ def test_SymLogNorm():
232233
assert_array_almost_equal(normed_vals, expected)
233234

234235

236+
@cleanup
237+
def test_SymLogNorm_colorbar():
238+
"""
239+
Test un-called SymLogNorm in a colorbar.
240+
"""
241+
norm = mcolors.SymLogNorm(0.1, vmin=-1, vmax=1, linscale=1)
242+
fig = plt.figure()
243+
cbar = mcolorbar.ColorbarBase(fig.add_subplot(111), norm=norm)
244+
plt.close(fig)
245+
246+
235247
def _inverse_tester(norm_instance, vals):
236248
"""
237249
Checks if the inverse of the given normalization is working.

0 commit comments

Comments
 (0)