1
1
import numpy as np
2
2
import pytest
3
3
4
+ from matplotlib import cm
5
+ import matplotlib .colors as mcolors
6
+
4
7
from matplotlib import rc_context
5
8
from matplotlib .testing .decorators import image_comparison
6
9
import matplotlib .pyplot as plt
7
10
from matplotlib .colors import (BoundaryNorm , LogNorm , PowerNorm , Normalize ,
8
11
DivergingNorm )
9
- from matplotlib .cm import get_cmap
10
12
from matplotlib .colorbar import ColorbarBase , _ColorbarLogLocator
11
13
from matplotlib .ticker import LogLocator , LogFormatter , FixedLocator
12
14
@@ -20,7 +22,7 @@ def _get_cmap_norms():
20
22
colorbar_extension_length.
21
23
"""
22
24
# Create a color map and specify the levels it represents.
23
- cmap = get_cmap ("RdBu" , lut = 5 )
25
+ cmap = cm . get_cmap ("RdBu" , lut = 5 )
24
26
clevs = [- 5. , - 2.5 , - .5 , .5 , 1.5 , 3.5 ]
25
27
# Define norms for the color maps.
26
28
norms = dict ()
@@ -240,7 +242,7 @@ def test_colorbar_closed_patch():
240
242
ax4 = fig .add_axes ([0.05 , 0.25 , 0.9 , 0.1 ])
241
243
ax5 = fig .add_axes ([0.05 , 0.05 , 0.9 , 0.1 ])
242
244
243
- cmap = get_cmap ("RdBu" , lut = 5 )
245
+ cmap = cm . get_cmap ("RdBu" , lut = 5 )
244
246
245
247
im = ax1 .pcolormesh (np .linspace (0 , 10 , 16 ).reshape ((4 , 4 )), cmap = cmap )
246
248
@@ -558,3 +560,11 @@ def test_extend_colorbar_customnorm():
558
560
cb = fig .colorbar (pcm , ax = ax [0 ], extend = 'both' )
559
561
np .testing .assert_allclose (cb .ax .get_position ().extents ,
560
562
[0.78375 , 0.536364 , 0.796147 , 0.9 ], rtol = 1e-3 )
563
+
564
+
565
+ def test_mappable_no_alpha ():
566
+ fig , ax = plt .subplots ()
567
+ sm = cm .ScalarMappable (norm = mcolors .Normalize (), cmap = 'viridis' )
568
+ fig .colorbar (sm )
569
+ sm .set_cmap ('plasma' )
570
+ plt .draw ()
0 commit comments