@@ -1233,6 +1233,34 @@ def test_imshow_quantitynd():
12331233 fig .canvas .draw ()
12341234
12351235
1236+ @check_figures_equal (extensions = ['png' ])
1237+ def test_norm_change (fig_test , fig_ref ):
1238+ # LogNorm should not mask anything invalid permanently.
1239+ data = np .full ((5 , 5 ), 1 , dtype = np .float64 )
1240+ data [0 :2 , :] = - 1
1241+
1242+ masked_data = np .ma .array (data , mask = False )
1243+ masked_data .mask [0 :2 , 0 :2 ] = True
1244+
1245+ cmap = plt .get_cmap ('viridis' ).with_extremes (under = 'w' )
1246+
1247+ ax = fig_test .subplots ()
1248+ im = ax .imshow (data , norm = colors .LogNorm (vmin = 0.5 , vmax = 1 ),
1249+ extent = (0 , 5 , 0 , 5 ), interpolation = 'nearest' , cmap = cmap )
1250+ im .set_norm (colors .Normalize (vmin = - 2 , vmax = 2 ))
1251+ im = ax .imshow (masked_data , norm = colors .LogNorm (vmin = 0.5 , vmax = 1 ),
1252+ extent = (5 , 10 , 5 , 10 ), interpolation = 'nearest' , cmap = cmap )
1253+ im .set_norm (colors .Normalize (vmin = - 2 , vmax = 2 ))
1254+ ax .set (xlim = (0 , 10 ), ylim = (0 , 10 ))
1255+
1256+ ax = fig_ref .subplots ()
1257+ ax .imshow (data , norm = colors .Normalize (vmin = - 2 , vmax = 2 ),
1258+ extent = (0 , 5 , 0 , 5 ), interpolation = 'nearest' , cmap = cmap )
1259+ ax .imshow (masked_data , norm = colors .Normalize (vmin = - 2 , vmax = 2 ),
1260+ extent = (5 , 10 , 5 , 10 ), interpolation = 'nearest' , cmap = cmap )
1261+ ax .set (xlim = (0 , 10 ), ylim = (0 , 10 ))
1262+
1263+
12361264@pytest .mark .parametrize ('x' , [- 1 , 1 ])
12371265@check_figures_equal (extensions = ['png' ])
12381266def test_huge_range_log (fig_test , fig_ref , x ):
0 commit comments