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

Skip to content

Commit 0ab4599

Browse files
tacaswellefiring
authored andcommitted
Merge pull request #6780 from Salganos/Salganos-SymLogNorm
ENH: Call _transform_vmin_vmax during SymLogNorm.__init__
1 parent 9aa02c6 commit 0ab4599

2 files changed

Lines changed: 14 additions & 0 deletions

File tree

lib/matplotlib/colors.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -987,6 +987,8 @@ def __init__(self, linthresh, linscale=1.0,
987987
Normalize.__init__(self, vmin, vmax, clip)
988988
self.linthresh = float(linthresh)
989989
self._linscale_adj = (linscale / (1.0 - np.e ** -1))
990+
if vmin is not None and vmax is not None:
991+
self._transform_vmin_vmax()
990992

991993
def __call__(self, value, clip=None):
992994
if clip is None:

lib/matplotlib/tests/test_colors.py

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

233234

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

0 commit comments

Comments
 (0)