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
@@ -20,7 +23,7 @@ def _get_cmap_norms():
20
23
colorbar_extension_length.
21
24
"""
22
25
# Create a color map and specify the levels it represents.
23
- cmap = get_cmap ("RdBu" , lut = 5 )
26
+ cmap = cm . get_cmap ("RdBu" , lut = 5 )
24
27
clevs = [- 5. , - 2.5 , - .5 , .5 , 1.5 , 3.5 ]
25
28
# Define norms for the color maps.
26
29
norms = dict ()
@@ -240,7 +243,7 @@ def test_colorbar_closed_patch():
240
243
ax4 = fig .add_axes ([0.05 , 0.25 , 0.9 , 0.1 ])
241
244
ax5 = fig .add_axes ([0.05 , 0.05 , 0.9 , 0.1 ])
242
245
243
- cmap = get_cmap ("RdBu" , lut = 5 )
246
+ cmap = cm . get_cmap ("RdBu" , lut = 5 )
244
247
245
248
im = ax1 .pcolormesh (np .linspace (0 , 10 , 16 ).reshape ((4 , 4 )), cmap = cmap )
246
249
@@ -558,3 +561,11 @@ def test_extend_colorbar_customnorm():
558
561
cb = fig .colorbar (pcm , ax = ax [0 ], extend = 'both' )
559
562
np .testing .assert_allclose (cb .ax .get_position ().extents ,
560
563
[0.78375 , 0.536364 , 0.796147 , 0.9 ], rtol = 1e-3 )
564
+
565
+
566
+ def test_mappable_no_alpha ():
567
+ fig , ax = plt .subplots ()
568
+ sm = cm .ScalarMappable (norm = mcolors .Normalize (), cmap = 'viridis' )
569
+ fig .colorbar (sm )
570
+ sm .set_cmap ('plasma' )
571
+ plt .draw ()
0 commit comments